I want to match some digits preceded by a non-digit or at the start of the string.
As the caret has no special meaning inside brackets I can't use that one, so I checked the reference and discovered the alternate form \A
.
However, when I try to use it I get an error:
>>> s = '123'
>>> re.findall('[\D\A]\d+', s)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 177, in findall
return _compile(pattern, flags).findall(string)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 245, in _compile
raise error, v # invalid expression
sre_constants.error: internal: unsupported set operator
What am I doing wrong?