Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.alphanet.ch!alphanet.ch!news.imp.ch!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Jim Gibson Newsgroups: comp.lang.java.programmer Subject: Re: regex capability Date: Mon, 04 Apr 2011 17:07:50 -0700 Lines: 25 Message-ID: <040420111707508648%jimsgibson@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: individual.net JetKgG8QIEhgPSh3n812GwFFecabeP2efmexM1/wd4xbRxwwXX X-Orig-Path: jimsgibson Cancel-Lock: sha1:GJqwDESiDteegzPT9nUYcPZ1UlE= User-Agent: Thoth/1.8.5 (OS X) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:2864 In article , Roedy Green wrote: > On Mon, 04 Apr 2011 02:34:30 -0500, Leif Roar Moldskred > wrote, quoted or indirectly quoted someone who > said : > > > > >Easiest is to just use split. You can always do a regex of the type > >"(\\d+)/((\\d+)/)?((\\d+)/)?((\\d+)/)?" but that's just pointlessly > >complicated. There's no reason why you should use a regex when "normal" > >string parsing is simpler and easier to read. > > (xxx|yyy)+ seems to generate only one group item, no matter how many > repetitions there are. That strikes me as a bug, but likely someone > can explain why it is a feature or inevitability. The "feature" is that the number of capture groups is equal to the number of capturing parenthesis pairs. If the above regular expression results in multiple matches, each match is captured and stored into the single capture buffer. After the match is finished, only the last captured substring remains in the single capture buffer. -- Jim Gibson