Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!usenetcore.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 15 Dec 2012 05:54:04 -0600 From: "Chris Uppal" Newsgroups: comp.lang.java.programmer References: <7f36342c-2331-4484-874b-4a0f8953f160@googlegroups.com> <50c61150$0$293$14726298@news.sunsite.dk> <50c6413a$0$293$14726298@news.sunsite.dk> <50c6598d$0$290$14726298@news.sunsite.dk> <50c69625$0$293$14726298@news.sunsite.dk> <50cbeec3$0$291$14726298@news.sunsite.dk> Subject: Re: multi-line Strings Date: Sat, 15 Dec 2012 11:54:15 -0000 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512 X-RFC2646: Format=Flowed; Original Message-ID: Lines: 40 X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-jLRR5PZLNg/qcmQNhKLnSKr4/MOGzMEXrU6ZUJB9gWb53ER2f5kVPm9DU4/REuQmD9bCEeC5iquBB4z!UvEzmQ1nh8wSaQnw2kJ4CylZBSxWK52RPk6yvdlP7yI+dz0CWzZvJd4Dt851OCFHq9YjZNnPQqpx X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3426 Xref: csiph.com comp.lang.java.programmer:20353 Arne Vajhøj wrote: > The regex syntax itself is not exactly a good example of readability. This, I think, is the point. We don't need a special String syntax to fix the problem with regexps -- we'd be much better off with a fixed regexp syntax. Something OO. And (since this is Java) I don't think that we need be afraid of something verbose. Off-the-top-of-my-head (all classes and method are imaginary): Regexp alpha = Regexp.fromList(java.lang.text.portable.Alphas); alpha = alpha.or('_'); Regexp num = Regexp.fromList(java.lang.text.portable.Digits); Regexp alphanum = alpha.or(num); Regexp identifier = alpha.followedBy(alphanum.repeated()); Naturally, I'd prefer something a /bit/ less verbose, but Java won't support that. But even with the verbosity, I think my version is /far/ better. It puts the composition of regexps into the programmer's hands which means that it can be approached like any other complex programming task. Quoting/escaping problems go away. Grouping (bracketing) problems go away (and become decoupled from the backreference concept. Comments become trivially easy to add. Various kinds of abstraction and reuse are possible. -- chris P.S. Mind you: my /real/ opinion is that regular expressions have no place in production code except in the construction of scanners (for which a more directly-applicable implementation than standalone regexps is helpful). Regexps are for users to enter, or go into configuration data. At least the suggestion above has the advantage -- from my point of view -- that regexps no longer look like "quick and easy" fixes to problems, and maybe the programmer would think more about whether they /actually/ solve [all of] the problem at hand. P.P.S UK post codes...