Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Daniele Futtorovic Newsgroups: comp.lang.java.programmer Subject: Re: regex capability Date: Mon, 04 Apr 2011 19:20:19 +0200 Organization: A noiseless patient Spider Lines: 26 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 4 Apr 2011 17:20:19 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="QSlUtCeZq+rhbhH2dxxF+A"; logging-data="2978"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+C6fesgXeQURNML5QUZFK" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 In-Reply-To: Cancel-Lock: sha1:I6TmfWyFZaAmIizJMYswxRRjUHQ= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:2850 On 04/04/2011 10:26, bugbear allegedly wrote: > 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. > > In Java, I use > > while(matcher.find()) { > ... > } > > The key is that Matcher is stateful. Yup. A regex is what you make of it. -- DF. An escaped convict once said to me: "Alcatraz is the place to be"