newbie regexp question
Fredrik Lundh
effbot at telia.com
Wed Apr 26 16:42:11 EDT 2000
mindlace <mindlace at imeme.net> wrote:
> I've got a re.compile('\W') that I can use to search for non-alphanumeric
> characters in a variable. However, if the variable has ( in it, for
example,
> the search breaks.
breaks?
> is there a quoted_var = string.quote(somevar) or similar? Do I want to
> use string.maketrans(somevar, quoted_var) ?
have no idea what you're talking about here, but maybe
re.escape does what you wants?
>>> import re
>>> print re.escape.__doc__
Escape all non-alphanumeric characters in pattern.
>>> print re.escape("(")
\(
</F>
More information about the Python-list
mailing list