Regex eating my characters

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”)
=> #MatchData:0x2e8cdc4
irb(main):003:0> $2
=> “tes”

YOu can see that it just ate the last t from $2. dunnno why.

Regadrs

Seede

On Jan 18, 2008 12:59 PM, Junkone [email protected] wrote:

irb(main):002:0> pattern.match(“list test”)
=> #MatchData:0x2e8cdc4
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

On Jan 18, 1:04 pm, Alex LeDonne [email protected] wrote:

group 1= any word
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- Hide quoted text -

  • Show quoted text -

thanks