Which special characters must be escaped when using Python regex module re?
10,002
After the opening square bracket the only special characters are -
, ^
and ]
:
[|\^&+\-%*/=!>]
You can find the list of special characters here:
Author by
Victor Brunell
Updated on July 03, 2022Comments
-
Victor Brunell over 1 year
I'm using the Python module re to write regular expressions for lexical analysis. I've been looking for a comprehensive list of which special characters must be escaped in order to be recognized by the regex to no avail. Can someone please point me to an exhaustive list?
The line in the current regex I'm writing that's giving me trouble is:
[\|\^&\+-%\*\/=!>]
I'd like it to recognize the characters:
|^&+-%*/=!>
Have I not escaped something I should have?