3 ms·
i didn't realize that it was possible to name a capturing group. this is an awesome example.
by logical42 14y ago
i didn't realize that it was possible to name a capturing group. this is an awesome example.
- aaronblohowiak 14y agoruby > 1.9
- pjscott 14y agoAlso available in Python's re module, with a syntax that's just different enough to be irritatingly incompatible. >>> import re >>> r = re.compile(r'(?P<month>\d{1,2})\/(?P<day>\d{1,2})\/(?P<year>\d{4})') >>> r.search("Today's date is: 10/23/2012.").groupdict() {'month': '10', 'day': '23', 'year': '2012'}