Remove all special characters, punctuation and spaces from string
This can be done without regex:
"Special $#! characters spaces 888323"''.join(e for e in string if e.isalnum())'Specialcharactersspaces888323'string =
You can use
S.isalnum() -> boolReturn True if all characters in S are alphanumericand there is at least one character in S, False otherwise.
If you insist on using regex, other solutions will do fine. However note that if it can be done without using a regular expression, that's the best way to go about it.