I\'m having a little trouble with Python regular expressions.
What is a good way to remove all characters in a string that are not letters or numbers?
Thanks
you can use predefined regex in python : \W corresponds to the set [^a-zA-Z0-9_]. Then,
\W
[^a-zA-Z0-9_]
import re s = 'Hello dutrow 123' re.sub('\W', '', s) --> 'Hellodutrow123'