Python RegExp
Since Python 3.12 whe you use regular expression pattern you could get SyntaxWarning: invalid escape sequence '\-'
error.
So this pattern will fail:
pattern='[^0-9a-zA-Z_\-\.]+'
This is because a backslash is only allowed when part of the valid escape sequence, like \n
.
You should use raw strings by prefixing your string with r
:
pattern=r'[^0-9a-zA-Z_\-\.]+'