Why can't the underscore be matched by '\W'?

Viewed 852

I know that _ cannot be matched by \W while any other punctuation can. As the docs state: \w is a set of alphanumeric characters and the underscore.

At the same time:

enter image description here

I have always been confused by this but never actually bothered to question why.

Does it have to do with the special role that _ plays in Python?

1 Answers
Related