I have a string:
s=\"123--abc,123--abc,123--abc\"
I tried using Ruby 1.9\'s new feature \"named groups\" to fetch all named group info:
Piggybacking off of Mark Hubbart's answer, I added the following monkey-patch:
class ::Regexp
def match_all(str)
matches = []
str.scan(self) { matches << $~ }
matches
end
end
which can be used as /(?
, and returns:
[#
This relies on, as others have said, the use of $~
in the scan block for the match data.