possible bug in re expression?
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Mon Apr 28 07:49:11 EDT 2014
On Mon, 28 Apr 2014 10:47:54 +0100, Robin Becker wrote:
> Does this in fact that almost any broken regexp specification will
> silently fail because re will reset and consider any metacharacter as
> literal?
Well, I don't know about "almost any", but at least some broken regexes
will explicitly fail:
py> import re
py> re.search('*', "123*4")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.3/re.py", line 161, in search
return _compile(pattern, flags).search(string)
[...]
File "/usr/local/lib/python3.3/sre_parse.py", line 552, in _parse
raise error("nothing to repeat")
sre_constants.error: nothing to repeat
(For brevity I have abbreviated the traceback.)
--
Steven D'Aprano
http://import-that.dreamwidth.org/
More information about the Python-list
mailing list