list of regex special characters

Ben Finney ben+python at
Mon Nov 29 01:13:14 CET 2010

goldtech <goldtech at> writes:

> I am looking for a list of special character in python regular
> expressions that need to be escaped if you want their literal meaning.

You can avoid caring about that by using ‘re.escape’, which escapes any
characters in its input character that are not alphanumeric.

> I searched and can not find the list. Any help appreciated.

    >>> import re
    >>> help(re)
        The special characters are: …

 \     “I got some new underwear the other day. Well, new to me.” —Emo |
  `\                                                           Philips |
_o__)                                                                  |
Ben Finney

More information about the Python-list mailing list