Reputation: 3461
How can I set the regular expression pattern other than SPECIFIC CHARACTER?
import re
str = 'abc?, def/ghi'
match = re.findall(r'[anything other than ',' or \s]', str)
print(match)
['abc?', 'def/ghi']
THX!!!
Upvotes: 0
Views: 35
Reputation: 59436
What about the straight forward
[^,]
which means exactly what you said. Did you even bother reading a regexp documentation? ;-)
For all except a comma and whitespace you can use the same approach:
[^,\s]
And to get a sequence of those use this:
[^,\s]+
Upvotes: 1