[issue2650] re.escape should not escape underscore

Morten Lied Johansen report at bugs.python.org
Sat Jun 28 22:51:59 CEST 2008


Morten Lied Johansen <mortenjo at ifi.uio.no> added the comment:

In my particular case, we were passing the regex on to a database which 
has regex support syntactically equal to Python, so it seemed natural 
to use re.escape to make sure we weren't matching against the pattern 
we really wanted.

The documentation of re.escape also states that it will only escape non-
alphanumeric characters, which is apparently only true if you are using 
a single byte encoding (ie. not utf-8, or any other encoding using more 
than a single byte per character). At the very least, that's probably 
worth mentioning in the docs.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2650>
_______________________________________


More information about the Python-bugs-list mailing list