I’m having a problem with a seemingly simple Python regular expression.
# e.g. If I wanted to find "mark has wonderful kittens, but they're mischievous.."
p = re.compile("*kittens*")
This will fail with the error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/re.py", line 190, in compile
return _compile(pattern, flags)
File "/usr/lib64/python2.7/re.py", line 242, in _compile
raise error, v # invalid expression
sre_constants.error: nothing to repeat
I’m probably missing something quite simple, regular expressions are certainly not in my strengths!
You’re confusing regular expressions with globs.
You mean:
Note that a bare asterisk doesn’t mean the same in an RE as it does in a glob expression.