If my string was:
Business -- way's
I'd like to turn this into:
Business ways
ie. replace NON abc/123 into ""
If my string was:
Business -- way's
I'd like to turn this into:
Business ways
ie. replace NON abc/123 into ""
Simple regular expression:
import re
>>> s = "Business -- way's"
>>> s = re.sub(r'[^\w\s]', '', s)
>>> s
"Business ways"
Or, if you don't want to use a regular expression for some reason:
''.join([x for x in foo if x.isalpha() or x.isspace()])
(regular expression) replace
[[:punct:]]
with '' (if Python supports that).
[] is a character class, [::] is posix class syntax. [:punct:] is punctuation, so the character class for all punctuation marks would be [[:punct:]]
An alternate way of the same thing is \p and friends: \p{IsPunct}
See just below "Character Classes and other Special Escapes" in http://perldoc.perl.org/perlre.html (yes, I know it's a Perl document, but this is more about regular expressions than Perl).
That being said, the first answer with [^\w\s] answers what you explained a little more explicitly. This was more just an explanation of how to do what your question asked.