Junkone
(Junkone)
1
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
A_LeDonne
(A LeDonne)
2
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, 2008 12:59 PM, Junkone <junkone1@gmail.com> 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")
=> #<MatchData:0x2e8cdc4>
irb(main):003:0> $2
=> "tes"
YOu can see that it just ate the last t from $2. dunnno why.