I want to match a string which is preceeded by a space or occurs at the
beginning of the line. I also don't want to catch the preceeding
character as a group.
I have found both of the following to work
re.compile('(?:^|\s)string')
re.compile('(?:\A|\s)string')
But would prefer to use the more concise [] notation. However
re.compile('[^\s]string')
Does not work and
re.compile('[\A\s]string')
throws an exception:
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Python24\Lib\sre.py", line 180, in compile
return _compile(pattern, flags)
File "C:\Python24\Lib\sre.py", line 227, in _compile
raise error, v # invalid expression
error: internal: unsupported set operator
Why don't either of these work (particularly the latter)?
Jeff
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor