>>> p = re.compile(r"^(\d{2}/\d{2}/\d{2})")
>>> p = re.compile(r"^(\d[2}/\d{2}/\d{4})")
Traceback (most recent call last):
File "
p = re.compile(r"^(\d[2}/\d{2}/\d{4})")
File "/usr/lib/python2.7/re.py", line 190, in compile
return _compile(pattern, flags)
File "/usr/lib/python2.7/re.py", line 245, in _compile
raise error, v # invalid expression
error: unexpected end of regular expression
The first regular expression compiles, the second one does not. The only difference I can see is the "4". What is going on here?
Ooops. Just before I was about to post this, I found the problem. Do you see it? It's not easy to see.
2 comments:
Open brackets will get you once and a while!
Open bracket will get you once in a while!
Post a Comment