On 11/28/2010 05:58 PM, goldtech wrote:
I am looking for a list of special character in python regular
expressions that need to be escaped if you want their literal meaning.

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

Trust the re module to tell you:

 >>> import re
 >>> chars = [chr(i) for i in range(0,256)]
 >>> escaped = [c for c in chars if re.escape(c) != c]
 >>> print len(escaped)
 194
 >>> print escaped
 [...]
 >>> can_use_unescaped = [c for c in chars if re.escape(c) == c]

(adjust "chars" accordingly if you want to check unicode characters too).

-tkc



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to