I\'m looking for a way to perform a regex match on a string in Ruby and have it short-circuit on the first match.
The string I\'m processing is long and from what it
I am not yet sure whether this feature is awesome or just totally crazy, but your regex can define local variables.
/\$(?\d+)\.(?\d+)/ =~ "$3.67" #=> 0 dollars #=> "3"
(Taken from http://ruby-doc.org/core-2.1.1/Regexp.html).