Regular expressions are patterns that describe character combinations in text. Use them in your searches to help describe concepts such as "sentences that begin with `The'" and "attribute values that contain a number." The following table lists the special characters in regular expressions, their meanings, and usage examples.
To search for text containing one of the special characters in the table, escape the special character with a backslash. For example, to search for the asterisk in the phrase "some conditions apply*," your search pattern might look like this: apply\*
. If you don't escape the asterisk, you'll find all the occurrences of "apply" (as well as any of "appl", "applyy", and "applyyy"), not just the ones followed by an asterisk.
Character | Matches | Example |
---|---|---|
^ |
Beginning of input or line. |
|
$ |
End of input or line. |
|
* |
The preceding character 0 or more times. |
|
+ |
The preceding character 1 or more times. |
|
? |
The preceding character 0 or 1 time. |
|
. |
Any single character except newline (line feed). |
|
x|y |
Either x or y. |
|
{n} |
Exactly n occurrences of the preceding character. |
|
{n,m} |
At least n and at most m occurrences of the preceding character. |
|
[abc] |
Any one of the characters enclosed in the brackets. Specify a range of characters with a hyphen (for example, [a-f] is equivalent to [abcdef]). |
|
[^abc] |
Any character not enclosed in the brackets. Specify a range of characters with a hyphen (for example, [^a-f] is equivalent to [^abcdef]). |
|
\b |
A word boundary (such as a space or carriage return). |
|
\B |
A non-word boundary. |
|
\d |
Any digit character. Equivalent to [0-9]. |
|
\D |
Any non-digit character. Equivalent to [^0-9]. |
|
\f |
Form feed. |
|
\n |
Line feed. |
|
\r |
Carriage return. |
|
\s |
Any single whitespace character, including space, tab, form feed, or line feed. |
|
\S |
Any single non-whitespace character. |
|
\t |
A tab. |
|
\w |
Any alphanumeric character, including underscore. Equivalent to [A-Za-z0-9_]. |
b\w* matches "barking" in "the barking dog" and both "big" and "black" in "the big black dog" |
\W |
Any non-alphanumeric character. Equivalent to [^A-Za-z0-9_]. |
\W matches "&" in "Jake & Mattie" and "%" in "100%" |