Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder2-2.proxad.net!news.osn.de!diablo2.news.osn.de!ecngs!feeder.ecngs.de!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail NNTP-Posting-Date: Mon, 04 Apr 2011 03:26:30 -0500 Date: Mon, 04 Apr 2011 09:26:29 +0100 From: bugbear User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20101213 Fedora/2.0.11-1.fc13 SeaMonkey/2.0.11 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: regex capability References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 28 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-w3RXIYni+iIMWcKi30SY7ZocJlzauxEpvkvIWHWwEB/J0+AfSrnMWx1q0vU5qCQPN+SOvg+NEmXjV6w!DFlCqv3Ppahw4vGFk+JOvR2i4VXYIVcBAX9vRu5yvGq32gfXnRek3bjnW+xmpTwpyqb+zz2ZQzVf!UN2ocnjeOt2nSpnnBaU0dCJybA== 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: 1801 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:2840 Roedy Green wrote: > Consider a string like this: > > Support DDR2 1066/800/667/533/400 DDR2 SDRAM > > Is it possible to compose a regex that will peel out those numbers for > you each in its own field, or do you have to extract the string > "1066/800/667/533/400" and use split? > > The various things I have tried just grab the last number. I think normal practice (in Perl, and Java) would be repeated use of a fairly simple regexp. In Java, I use while(matcher.find()) { ... } The key is that Matcher is stateful. The perl version is while (/pattern/g) { print "Found $1\n"; } BugBear