J
Junkone
When i match a pattern and if it returns a nil, obviously the regex
did not match the pattern. is there a way of identifying which set did
not match
pattern=Regexp.new('([g|l])\s+([0-9\.]+)')
irb(main):073:0> pattern.match('g 32')
=> #<MatchData:0x2e158b4>
irb(main):074:0> pattern.match('g we')
=> nil
irb(main):075:0>
If i can detect that the $2 failed and $1 was ok, i can pass more
intelligent error messages.
did not match the pattern. is there a way of identifying which set did
not match
pattern=Regexp.new('([g|l])\s+([0-9\.]+)')
irb(main):073:0> pattern.match('g 32')
=> #<MatchData:0x2e158b4>
irb(main):074:0> pattern.match('g we')
=> nil
irb(main):075:0>
If i can detect that the $2 failed and $1 was ok, i can pass more
intelligent error messages.