I just wanted to say that if you stumble with a regex try Regexp::Debugger.
It saved me twice today facing problems too silly to describe here. :-)
Here is how I proceeded:
- write regex and see it not doing what I want
- think, rewrite, think again, rising anger
- insert Regexp::Debugger the line before regex
- play the regex, facepalm (in a positive way)
I now think about writing more complicated regexes. I want to enjoy the debugger even longer. ;-)