New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hierarchical regular expression #41783
Comments
( from the re2 sourceforge project The re2 library provides a hierarchical regular re2 extracts a hierarchy of named groups from a string, >>> import re
>>> buf='12 drummers drumming, 11 pipers piping, 10
lords a-leaping'
>>> regex='^((?P<verse>(?P<number>\d+)
(?P<activity>[^,]+))(, )?)*$'
>>> pat1=re.compile(regex)
>>> m=pat1.match(buf)
>>> m.groupdict()
{'verse': '10 lords a-leaping', 'number': '10',
'activity': 'lords a-leaping'}
>>> import re2
>>> buf='12 drummers drumming, 11 pipers piping, 10
lords a-leaping'
>>> regex='^((?P<verse>(?P<number>\d+)
(?P<activity>[^,]+))(, )?)*$'
>>> pat2=re2.compile(regex)
>>> x=pat2.extract(buf)
>>> x
{'verse': [{'number': '12', 'activity': 'drummers
drumming'}, {'number': '11', 'activity': 'pipers
piping'}, {'number': '10', 'activity': 'lords a-leaping'}]} (See http://pyre2.sourceforge.net/ for more details.) |
Logged In: YES Is this a patch? If so, where is the code, and are you its |
Logged In: YES Sorry, it's more an extension than a patch. The code is in this subversion repository: Or available for download here: And has a development wiki here: And yes, I'm the author. |
Logged In: YES We accept extensions only by means of patches. So you would However, in the specific case, I think whether or not the |
Logged In: YES Ok. |
Logged In: YES Given the discussion of python-dev, it appears that you want |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: