| Next | Regular Expression Mastery | 46 |
\d \D \w \W \s \S
These are just character classes.
| \d | [0-9] |
| \D | [^0-9] |
| \w | [A-Za-z0-9_] |
| \W | [^A-Za-z0-9_] |
| \s | [ \t\n\f\r] |
| \S | [^ \t\n\f\r] |
Actually they depend on the locale, so they're not only shorter, they're also safer
Example: In France, \w will match É and ï.
But [A-Za-z0-9_] only includes E and i.
| Next | ![]() |
Copyright © 2002 M. J. Dominus |