X-Received: by 10.66.84.97 with SMTP id x1mr2508789pay.7.1359840185183; Sat, 02 Feb 2013 13:23:05 -0800 (PST) X-Received: by 10.50.191.131 with SMTP id gy3mr252569igc.1.1359840185002; Sat, 02 Feb 2013 13:23:05 -0800 (PST) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!ld4no538622pbb.0!news-out.google.com!s9ni31583pbb.0!nntp.google.com!ld4no538616pbb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Sat, 2 Feb 2013 13:23:04 -0800 (PST) In-Reply-To: <510d7f3c$0$289$14726298@news.sunsite.dk> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.164.137.214; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T NNTP-Posting-Host: 173.164.137.214 References: <5109e49b$0$295$14726298@news.sunsite.dk> <510c380b$0$287$14726298@news.sunsite.dk> <510c3e29$0$287$14726298@news.sunsite.dk> <510d7f3c$0$289$14726298@news.sunsite.dk> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Regex: Any character in character class From: Lew Injection-Date: Sat, 02 Feb 2013 21:23:05 +0000 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Xref: csiph.com comp.lang.java.programmer:22026 Arne Vajh=F8j wrote: > Sebastian wrote: >> schrieb Arne Vajh=EF=BF=9Cj: >> [snip] >>> And also round brackets for the last part. >>> >>> .+?:(.|\n)+ >>> >>> I think I must have set a new world record. 3 bugs in 12 characters. >=20 >>> :-( >=20 >> Here's a concrete example: >> >> SCA:LIST, select[werks_s:default_plant],values[bukrs:bukrs, >> company:company] >=20 >> The second part is everything after the first comma. I was using You mean 'expression.substring(expression.indexOf(',') + 1)'? (modulo the usual error checks, of course) > > (.+?),[\s\S]+ >> Arne's suggestion modified for my needs (comma as separator, and I only >> want to capture the first part as a group) will work fine as well: You mean 'expression.substring(0, expression.indexOf(','))'? > > (.+?),(?:.|\n)+ >=20 >> Can't say though that I find anything to prefer the one to the other. >> Perhaps the second looks even more like the result of a cat walk... If all you need to do is split a string on a comma, why use regexes at all? > It is not unusual that there is more than one regex that > does the job. It is not unusual that there is more than one non-regex that does the job. --=20 Lew