13

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
  • 475
  • 9
  • 18

1 Answers1

20

Yes, like that: [^\W_]

Where \W is the opposite of \w

Casimir et Hippolyte
  • 88,009
  • 5
  • 94
  • 125