October 2006
Intermediate to advanced
888 pages
16h 55m
English
Character classes are simply a form of alternation (specification of alternative possibilities) where each submatch is a single character. In the simplest case, we list a set of characters inside square brackets:
/[aeiou]/ # Match any single letter a, e, i, o, u; equivalent
# to /(a|e|i|o|u)/ except for group-captureInside a character class, escape sequences such as \n are still meaningful, but metacharacters such as . and ? do not have any special meanings:
/[.\n?]/ # Match any of: period, newline, question mark
The caret (^) has special meaning inside a character class if used at the beginning; it negates the list of characters (or refers to their complement):
[^aeiou] # Any character EXCEPT a, e, i, o, u
The hyphen, ...
Read now
Unlock full access