Character |
Match |
Example |
^ |
The start part of the input or line. |
^ T matches "T" in "this good earth", but does not match "T" in "Uncle Tom's Cabin ". |
$ |
The end of the input or line. |
H $ matches "h" in "teach", but does not match "h" in "teacher" |
* |
0 or multiple prefix characters. |
Um * matches "um" in "Rum", "UMM" in "yummy", and "U" in "huge" |
+ |
One or more preconditions. |
Um + matches "um" in "Rum" and "UMM" in "yummy", but there is no match in "huge" |
? |
The prefix can appear at most once (that is, it indicates that the prefix is optional ). |
St? On matches "son" in "Johnson" and "ston" in "Johnston", but there are no matching items in "Appleton" and "tension ". |
. |
Any single character except line breaks. |
. An matches "ran" and "can" in the phrase "bran muffins can be tasty" |
X | y |
X or Y. |
Ff0000 | 0000ff matches "0000ff" in "ff0000" and "Font color =" # 0000ff "in" # ff0000" |
{N} |
Exactly n prefix characters. |
O {2} matches the first two "O" in "loom" and "mooooo", but there is no match in "money" |
{N, m} |
At least N and at most M prefixes. |
F {2, 4} matches the first four "F" in "# ff0000" and "# ffffff" |
[ABC] |
Any of the characters enclosed in parentheses. Use a hyphen to specify a range of characters (for example, [A-F] is equivalent to [abcdef]). |
[E-G] matches "G" in "E" in "bed", "F" in "folly", and "guard" |
[^ ABC] |
Any character not enclosed in parentheses. Use a hyphen to specify a range of characters (for example, [^ A-F] is equivalent to [^ abcdef]). |
[^ Aeiou] initially matches "B" and "Eek!" in "R" and "book" in "orange !" "K" in" |
\ B |
Word boundary (for example, space or carriage return ). |
\ BB matches "B" in "book", but there are no matches in "Goober" and "snob" |
\ B |
Any content beyond the word boundary. |
\ BB matches "B" in "Goober", but there is no match in "book" |
\ D |
Any number character. It is equivalent to [0-9]. |
\ D matches "2" in "3" and "Apartment 2G" in "C3PO" |
\ D |
Any non-numeric character. It is equivalent to [^ 0-9]. |
\ D matches "S" in "900s" and "Q" in "q45" |
\ F |
Page Break. |
|
\ N |
Line Break. |
|
\ R |
Carriage return. |
|
\ S |
Any single blank character, including space, tab, break, or line break. |
\ Sbook matches "book" in "Blue book", but there is no match in "Notebook" |
\ S |
Any single non-blank character. |
\ Sbook matches "book" in "Notebook", but there is no match in "Blue book" |
\ T |
Tab. |
|
\ W |
Any letter, digit, or underscore. It is equivalent to [A-Za-z0-9 _]. |
B \ W * matches "Barking" in "the barking dog" and "big" and "black" in "the big black dog" |
\ W |
Any non-alphanumeric character. It is equivalent to [^ A-Za-z0-9 _]. |
\ W matches |