Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.news-service.com!216.196.110.144.MISMATCH!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.telenor.com!news.telenor.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 04 Apr 2011 02:34:30 -0500 From: Leif Roar Moldskred Subject: Re: regex capability Newsgroups: comp.lang.java.programmer References: User-Agent: tin/1.9.6-20100522 ("Lochruan") (UNIX) (Linux/2.6.35-28-generic-pae (i686)) Message-ID: Date: Mon, 04 Apr 2011 02:34:30 -0500 Lines: 19 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-c9uLCrfEbJt48eQ4B/tIw1j7S3S5Gf5nBMCyt4vJ8rzKg+ngG0eaHz5suwDJLkoZkwI/DsLvNKEO50D!ysm+0Dk5UE/mhyjFu3o4wkN4XGD2dRs/hleMOMf8tMTKC5CE5VPf9caxDEA4Y0k+4fZbIX8z7pzx!nh14OiMi X-Complaints-To: news-abuse@telenor.net X-DMCA-Complaints-To: news-abuse@telenor.net 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: 1693 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:2838 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. 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. -- Leif Roar Moldskred