Hi,
Does Ruby support regexps that assign names to specific matched
groups? In Python, for instance, if you write a regexp like this,
TEMP_RE = re.compile(r"""^(?P<temp>(M|-)?\d+|//|XX|MM)/
(?P<dewpt>(M|-)?\d+|//|XX|MM)?\s+""",
re.VERBOSE)
the match object will provide a hash with keys 'temp' and 'dewpt',
containing the values matched by the corresponding '(?P<temp>...).
and '(?P<dewpt>...)' groups. This is another solution to the problem
of creating regexps where you want to parentheses both for grouping
and substring capture. I know Perl and Ruby support the '(?:...)'
syntax to let you use parens for specifying alternatives without
capturing that group, but the Python scheme for labeling capture
groups produces more readable code, and I've used it heavily in some
code I was hoping to port to Ruby. I was hoping that perhaps I'd
just overlooked something in the Ruby docs.
Thanks,
Tom