In most, if not all implementations of regular expressions, the \w metacharacter matches all alphanumeric characters plus the underscore.
Historically speaking, why was the underscore character included in this character class? And why not include dashes too?
identifiers_like_this
. Don't use\w
if you need a specific meaning like letters – either use POSIX charclasses like[[:alnum:]]
or Unicode properties for that, depending on what your regex engine offers and what you need exactly. – amon May 02 '14 at 22:55