On Friday, March 18, 2016 at 4:17:06 AM UTC+5:30, MRAB wrote:
> Stick an "x" on the end of the regex: /something/x or s/old/new/x.
Thanks!
Is there somewhere a regexp 'introspection' API/capability available?
ie if the re looks like
rexp = r"""
# DSL (instantiation) for describing NYSE symbology
^
(?P<scrip> [A-Z]*) # The base scrip
(?P<serchar> [.+-])? # Series type char
(?P<series> [A-Z])? # Series
(?P<issuedc> [#])? # issued char indicator
$ # Thats all (there should be!)
"""
I would like to know that the named-groups are
{scrip, serchar, series, issued}
without doing match/search etc
That way then the same DSL could be used for quite different regexps
IOW I would like to generalize the code:
g = m.group
scrip, serchar, series, issuedc = g('scrip'), g('serchar'), g('series'),
g('issuedc')
The scrip, serchar, series etc need not be local vars;
a dict is fine/preferable
--
https://mail.python.org/mailman/listinfo/python-list