[ python-Bugs-1113484 ] document {m} regex matcher wrt empty matches

SourceForge.net noreply at sourceforge.net
Mon Jan 31 22:46:48 CET 2005


Bugs item #1113484, was opened at 2005-01-31 22:46
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1113484&group_id=5470

Category: Regular Expressions
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Wummel (calvin)
Assigned to: Gustavo Niemeyer (niemeyer)
Summary: document {m} regex matcher wrt empty matches

Initial Comment:
The {m} matcher seems not to be applicable to (some)
empty matches. For example this will raise a regex
compile error:
>>> re.compile("(a*){4}")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/sre.py", line 179, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python2.3/sre.py", line 230, in _compile
    raise error, v # invalid expression
sre_constants.error: nothing to repeat

However this matcher is compiled without error:
>>> re.compile("(\ba*){4}")
<_sre.SRE_Pattern object at 0xb7f86c58>

I don't know why the first example gives an error, but
it should perhaps be mentioned in the documentation
about the {} regex operator.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1113484&group_id=5470


More information about the Python-bugs-list mailing list