Bugs item #1113484, was opened at 2005-01-31 22:46 Message generated for change (Comment added) made by calvin 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. ---------------------------------------------------------------------- >Comment By: Wummel (calvin) Date: 2005-02-03 18:06 Message: Logged In: YES user_id=9205 Oops, it should have been: >>> re.compile(r"(\ba*){4}") And now the error is consistent (now tested in Python 2.4 instead of 2.3): Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/sre.py", line 180, in compile return _compile(pattern, flags) File "/usr/lib/python2.4/sre.py", line 227, in _compile raise error, v # invalid expression sre_constants.error: nothing to repeat So it seems that {m} operator does not like potentially empty matches. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1113484&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com