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
non-greedy regexp duplicating match bug #34572
Comments
I found some weird bug, where when a non-greedy match doesn't match anything, #pyrebug.py:
import re
urlrebug=re.compile("""
(.*?):// #scheme
(
(.*?) #user
(?:
:(.*) #pass
)?
@)?
(.*?) #addr
(?::([0-9]+))? #port
(/.*)?$ #path
""", re.VERBOSE)
testbad='foo://bah:81/pth' print urlrebug.match(testbad).groups() Bug Output:
Good (expected) Output:
|
Logged In: NO What's happening makes sense, on one level. ((.*?)(?::(.*))?@)? which fill groups 2, 3, and 4, the .*? of group 3 has What you'd like to happen is when that "bailing" happens I'm not explaining this well -- I hope you can understand
|
Logged In: YES I think I understand what you are saying, and in the context So I'd just get: ('foo', 'bah:81/pth', None, 'bah', '81', Knowing the general ease of messing up regexs when writing |
Logged In: YES This looks like the same bug I have reported (with a much simpler example) |
Logged In: YES Ok, after poking and prodding the _sre.c code a bunch until |
Logged In: YES This problem was fixed in the following CVS revisions: Lib/test/re_tests.py:1.30->1.31 Thank you! |
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: