[Python-bugs-list] [ python-Bugs-406815 ] python2.1b re bug (.*)?
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 16 Mar 2001 09:50:31 -0800
Bugs item #406815, was updated on 2001-03-07 12:32
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=406815&group_id=5470
Category: Regular Expressions
Group: None
Status: Open
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
>Assigned to: Fredrik Lundh (effbot)
Summary: python2.1b re bug (.*)?
Initial Comment:
The script below works per expectation with python1.5.
It fails with python2.1b1
% python2.1 gar
Traceback (most recent call last):
File "gar", line 9, in ?
mob = re.search("== Parameters ==\n(.*)?\s*$",
output, re.S)
File "/usr/local/lib/python2.1/sre.py", line 55, in
search
return _compile(pattern, flags).search(string)
File "/usr/local/lib/python2.1/sre.py", line 131, in
_compile
raise error, v # invalid expression
sre_constants.error: nothing to repeat
Move "?" inside the parens and it works. Replace the
"*" with a "+" and it works (at least for this example
input).
import re
output = """
Using
== Parameters ==
line1
line2
"""
mob = re.search("== Parameters ==\n(.*)?\s*$", output,
re.S)
print mob.groups()
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=406815&group_id=5470