user3002486 user3002486 - 6 months ago 18
Python Question

Python regex expression, what does +X mean?

I'm having trouble figuring out what exactly this regex pattern is searching for mostly due to the number at the end. From what I can tell, it is saying search for any character that is not a-z and repeat it for the whole string. What does the 3 do?




In a character class all characters loose their special meaning (if any), only the first ^ is used to negate the class, - is used to define a range (except at the first and last position), an eventual backslash may start an escape sequence and ] closes the class.

3 is the literal character 3, + is the literal character +, . is a literal ., nothing more.

[^a-z.+3] matches one character that isn't in this list and is the same as [^.a-z3+] or [^+.a-z3]