From: Tom Armitage Date: 2006-09-29T18:37:06+09:00 Subject: Re: Regexp help But, of course, that *won't* capture "3m 2h", like you described... On 29/09/06, Steve Callaway wrote: > ah neat, Jordan, and more elegant than parsing an > arrayh of regexps:) > > --- MonkeeSage wrote: > > > Marcus Bristav wrote: > > > Is there a smart regexp one liner that could > > produce > > > > > > [2, 3] > > > > r = Regexp.new(/(\d+)h.*(\d+)m/) > > s1 = "2h 3m" > > s2 = "2h 3minutes" > > s3 = "2hour 3min" > > m = r.match(s1) > > p [m[1].to_i, m[2].to_i] # => [2, 3] > > m = r.match(s2) > > p [m[1].to_i, m[2].to_i] # => [2, 3] > > m = r.match(s3) > > p [m[1].to_i, m[2].to_i] # => [2, 3] > > > > Regards, > > Jordan > > > > > > > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > >