problem with regex
Tim Chase
python.list at tim.thechases.com
Fri Jul 28 09:16:23 EDT 2006
> p = re.compile(r'[A-Za-z]:\\([^/:\*?"<>\|])*')
>
> x = p.match("c:\test")
> any ideas why? i escape the back-slash, the asterisk *, and the PIPE |
> ....b/c they are regex special characters.
Same problem, only now in the other string:
>>> s = "c:\test"
>>> print s
c: est
Your "\t" is interpreted as as tab character. Thus, you want
s = r"c:\test"
or
s = "c:\\test"
which you'll find should now be successfully found with
p.match(s)
-tkc
More information about the Python-list
mailing list