11

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!

nilsonneto
  • 455
  • 9
  • 17

1 Answers1

16

Yes, like that: [^\W_]

Where \W is the opposite of \w

Casimir et Hippolyte
  • 85,718
  • 5
  • 90
  • 121