Character Class Description Pattern Matches
Character Class Description Pattern Matches
[ character_group ] Matches any single character in character_group. By default, the match is case- [ae] "a" in "gray"
sensitive. "a", "e" in lane"
[^ character_group ] Negation: Matches any single character that is not in character_group. By default, [^aei] "r", "g", "n" in "reign"
characters in character_group are case-sensitive.
[ first - last ] Character range: Matches any single character in the range from first to last. [A-Z] "A", "B" in "AB123"
. Wildcard: Matches any single character except \n. a.e "ave" in "nave"
"ate" in "water
To match a literal period character (. or \u002E), you must precede it with the escape
character (\.).
\w Matches any word character. \w "I", "D", "A", "1", "3" in "ID
A1.3"
\W Matches any non-word character. \W " ", "." in "ID A1.3"
\s Matches any white-space character. \w\s "D " in "ID A1.3"
\S Matches any non-white-space character. \s\S " _" in "int __ctr"
\d Matches any decimal digit. \d "4" in "4 = IV"
\D Matches any character other than a decimal digit. \D " ", "=", " ", "I", "V" in "4 =
IV"
"19302" in "193024"
Anchors Description Pattern Matches
^ By default, the match must start at the beginning of the string; in multiline mode, it ^\d{3} "901" in
must start at the beginning of the line.
"901-333-"
$ By default, the match must occur at the end of the string or before \n at the end of -\d{3}$ "-333" in
the string; in multiline mode, it must occur before the end of the line or before \n at
the end of the line. "-901-333"