Here are some windows results with Python 2.7:
>>> import re
>>> re.match("()*?1", "1")
<_sre.SRE_Match object at 0x025C0E60>
>>> re.match("()+?1", "1")
>>> re.match("()+?1", "11")
<_sre.SRE_Match object at 0x025C0E60>
>>> re.match("()*?1", "11")
<_sre.SRE_Match object at 0x025C3C60>
<_sre.SRE_Match object at 0x025C3C60>
>>> re.match("()*?1", "a1")
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
re.match("()*?1", "a1")
File "C:\Python27\lib\re.py", line 137, in match
return _compile(pattern, flags).match(string)
MemoryError
>>> re.match("()+?1", "a1")
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
re.match("()+?1", "a1")
File "C:\Python27\lib\re.py", line 137, in match
return _compile(pattern, flags).match(string)
MemoryError
Note that when matching to a string starting with "1", the matcher will not throw a MemoryError. |