A Regular Expression in Python that accepts letters,numbers and only these special characters (,.-|;!_?).
I have tried solving the problem through the following regular expressions but it didn't work:
'([a-zA-Z0-9,.-|;!_?])$'
'([a-zA-Z0-9][.-|;!_?])$'
Can someone please help me write the regular expression.
I think the following should work (tested on RegExr against
Foo123,.-|;!_?
):In your regular expressions, you forget to escape the '-' character, which is interpreted as a range of characters to match against.