Submitted by cyent (Wed Nov 19 17:11:39 UTC 2003)
You got it wrong, but you have no idea how.
Or worse, your user has entered input wrong, and you can't tell him what, just that it is wrong.
Any sensible parser when choking on input will tell you, 'Syntax Error: Expecting one of "blah,bloo,foo"', so why can't Ruby Regex's?
For example if I try match
"digger" =~ /dig(by|raph)/
expecting to match either digby or digraph it would be nice if Ruby could tell me, "No match, expecting a character in set [br] but found 'g' at position 3"
There are several ways in which this could be achieved...
"digby" =~ /dig(by|raph)/ewould return false, but set some global $whatever with the MatchData
Comments | Current voting | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
RCRchive copyright © David Alan Black, 2003-2005.
Powered by .
Regex engine in Ruby YUCK! (neoneye2, 2003-11-19 13:22:18)
Current status:
This would be great (sodell, 2003-11-19 21:32:35)
May I suggest a modification?
Do the /exp/e thing, but let /e denote that an exception should be thrown, and throw a custom exception which contains the match error information.