How to match all alphanumeric characters except underscore in Python

I am trying to combine all alphanumeric characters with a regular expression except underscore. I am currently using r"^[a-zA-Z0-9]*", but I was wondering if you can use \wand exclude _.

Thank!

+4
source share
1 answer

Yes, like this: [^\W_]

Where \Wopposite\W

+9
source

Source: https://habr.com/ru/post/1541688/


All Articles