| Symbol | Description | Pattern | Pattern Matches |
| \ |
Indicates next character should not be interpreted literally if it normally is, and should be interpreted literally if it normally isn't |
a\sc |
a c |
| ^ |
Matches beginning of input or line |
^abc |
abc, abcdefg, abc123, ... |
| $ |
Matches end of input or line |
abc$ |
abc, endsinabc, 123abc, ... |
| * |
Matches 0 or more instances of preceding character |
ab*c |
ac, abc, abbc, abbbc, ... |
| + |
Matches 1 or more instances of preceding character |
ab+c |
abc, abbc, abbbc, ... |
| ? |
Matches 0 or 1 instances of preceding character |
ab?c |
ac, abc |
| . (period) |
Matches any single character other than the newline character |
a.c |
abc, aac, acc, adc, aec, ... |
| (x) |
Matches x and remembers the match |
(abc){2} |
abcabc |
| \n |
A reference to the last substring matching the nth parenthetical (where n is a positive integer). Backreferences allow you to reuse part of the regex match. |
([a-c])x\1x\1 |
axaxa, bxbxb and cxcxc |
| x|y (pipe) |
Matches either x or y |
bill|ted |
ted, bill |
| {n} |
Matches exactly n instances of preceding character (where n is an integer) |
ab{2}c |
abbc |
| {n,} |
Matches at least n instances of preceding character (where n is an integer) |
\s{2,} matches at least 2 whitespace characters. |
| {n,m} |
Matches it least n and at most m instances of preceding character (where n and m are integers) |
\d{2,4} matches at least 2 but no more than 4 digits. |
| [xyz] |
Matches any one of enclosed characters (specify range using hyphen, such as [0-9] |
a[bB]c |
abc, aBc |
| [^xyz] |
Matches any character not enclosed (specify range using hyphen, such as [^0-9] |
Opposite of above |
| [\b] |
Matches a backspace |
Self Explanatory |
| \b |
Matches a word boundary, such as a space. (test characters must exist at the beginning or end of a word within the string) |
ly\b matches "ly" in "This is really cool." |
| \B |
Matches a nonword boundary |
\Bor matches "or" in "normal" but not "origami." |
| \d |
Matches a digit character (same as [0-9]) |
\d* matches "123" in "abc123" |
| \D |
Matches a nondigit character (same as [^0-9]) |
\D* matches "abc" in "abc123" |
| \f |
Matches a form feed |
Self Explanatory |
| \n |
Matches a line feed |
Self Explanatory |
| \r |
Matches a carriage return |
Self Explanatory |
| \s |
Matches a single white space character, including space, tab, form feed, and line feed (same as [\f\n\r\t\v]) |
Self Explanatory |
| \S |
Matches a single non-white-space character (same as [^\f\n\r\t\v]) |
Self Explanatory |
| \t |
Matches a tab |
Self Explanatory |
| \v |
Matches a vertical tab |
Self Explanatory |
| \w |
Matches any alphanumeric character, including the underscore (same as [A-Za-z0-9_]) |
\w* matches "123" in "123%" |
| \W |
Matches any nonword character (same as [^A-Za-z0-9_]) |
\W* matches "%" in "123%" |