Reputation: 495
I've been trying to match with regex all alphanumeric characters, except for the underscore.
I'm currently using r"^[a-zA-Z0-9]*"
, but I wondered if it was possible to use \w
and exclude _
.
Thanks!
Upvotes: 15
Views: 6111
Reputation: 89584
Yes, like that: [^\W_]
Where \W
is the opposite of \w
Upvotes: 22