Because it's not supposed to (per the documentation). It's a Perl "word" character--not necessarily what you'd think of as an English "word" character. Think of it as valid characters for a variable name.
$my_var (valid) $new_var_123 (valid) $stuff-animals (not valid) On Wed, Jun 1, 2011 at 10:55 AM, <[email protected]> wrote: > Why would it not match a hyphen then? > > > > On Jun 1, 2011, at 10:40, Joseph Scott <[email protected]> wrote: > > > Specifically \w matches any "word character". This is explained in > > PHP land - http://us3.php.net/manual/en/regexp.reference.escape.php - > > as: > > > > "A "word" character is any letter or digit or the underscore > > character, that is, any character which can be part of a Perl "word". > > The definition of letters and digits is controlled by PCRE's character > > tables, and may vary if locale-specific matching is taking place. For > > example, in the "fr" (French) locale, some character codes greater > > than 128 are used for accented letters, and these are matched by \w." > > > > So exactly what \w will match can change depending on the the > > environment. That's why it is traditionally described as matching > > "word" characters. > > > > > > On Wed, Jun 1, 2011 at 9:51 AM, Wade Preston Shearer > > <[email protected]> wrote: > >> The regex shortcode \w is supposed to match 0-9, A-Z, and a-z. It is > allowing an underscore though. Any ideas why? > > > > > > > > -- > > Joseph Scott > > [email protected] > > http://josephscott.org/ > > _______________________________________________ > > UPHPU mailing list > [email protected] > http://uphpu.org/mailman/listinfo/uphpu > IRC: #uphpu on irc.freenode.net > _______________________________________________ UPHPU mailing list [email protected] http://uphpu.org/mailman/listinfo/uphpu IRC: #uphpu on irc.freenode.net
