From: Alex LeDonne Date: 2008-01-19T03:04:53+09:00 Subject: Re: regex eating my characters On Jan 18, 2008 12:59 PM, Junkone wrote: > Hello > I am having trouble with this regex > > My pattern is > group 1= any word > Group 2= any word > group 3 = any sentence > > irb(main):001:0> pattern= Regexp.new('(\S+)\s+(\S+)(.+)') > => /(\S+)\s+(\S+)(.+)/ > irb(main):002:0> pattern.match("list test") > => # > irb(main):003:0> $2 > => "tes" > > > YOu can see that it just ate the last t from $2. dunnno why. Nah, it's in $3... if it wasn't available for your (.+), there wouldn't be a match. Did you mean (.*) at the end? -A