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
re.compile("(.*$){1,4}", re.MULTILINE) fails #44451
Comments
[forwarded from http://bugs.debian.org/289603] Trying to match 1-4 lines of arbitrary content (as part of a larger regex) using the expression (.*$){1,4} and re.MULTILINE. This caused the re module to raise the error "nothing to repeat". $ python2.5
Python 2.5 (release25-maint, Dec 13 2006, 16:21:45)
[GCC 4.1.2 20061212 (prerelease) (Ubuntu 4.1.1-21ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re.compile("(.*$){1,4}", re.MULTILINE)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/re.py", line 180, in compile
return _compile(pattern, flags)
File "/usr/lib/python2.5/re.py", line 233, in _compile
raise error, v # invalid expression
sre_constants.error: nothing to repeat |
On first blush, this issue sounds quite similar to bpo-2537, but I (?m)(?:.*$)(.*$) is the same as: (?m)(.*$){2} Yet the former compiles while the later raises the exception you list As a working alternative, you could write r'(?m)(?:(.*$)[\r\n]*){1,4}' , Since we don't want to change the meaning of $ and ^ to make them |
Can this be closed as a duplicate of bpo-2537? |
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: