Character |
The |
Example |
^ |
The starting part of the input or line. |
^t matches "T" in "This Good the Earth", but does not match "T" in "Uncle Tom's Cabin". |
$ |
The end part of the input or line. |
h$ matches "H" in "teach", but does not match "H" in "Teacher" |
* |
0 or more preceding characters. |
um* matches "Umm" in "um", "Yummy" in "Rum" and "U" in "huge" |
+ |
1 or more preceding characters. |
um+ matches "Umm" in "um" and "Yummy" in "Rum", but there are no matches in "huge" |
? |
The preceding character appears at most once (that is, indicates that the preceding character is optional). |
St?on matches "Ston" in "Son" and "Johnston" in "Johnson", but there are no matches in "Appleton" and "Tension" |
. |
Any single character except a newline character. |
"Ran" and "can" in a matching phrase "bran muffins can be tasty" |
X|y |
x or Y. |
FF0000|0000FF matches "0000FF" in "FF0000" and Font color= "#0000FF" in Bgcolor= "#FF0000" |
N |
Exactly n a preceding character. |
O{2} matches the first two "O" in "oo" and "mooooo" in "loom", but there are no matches in "money" |
{N,m} |
At least N, at most m, preceding characters. |
f{2,4} matches the first four "F" in "FF" and "#FFFFFF" in "#FF0000" |
[ABC] |
Any one of the characters enclosed in parentheses. Specifies a range of characters with hyphens (for example, [a-f] is equivalent to [abcdef]). |
[E-g] matches "G" in "F" and "guard" in "E", "Folly" in "bed" |
[^ABC] |
Any character that is not enclosed in parentheses. Specifies a range of characters with hyphens (for example, [^a-f] is equivalent to [^abcdef]). |
[^aeiou] Initially matches the "B" and "eek!" in "Orange" in "R", "book" "K" in the |
\b |
Word boundaries (such as spaces or carriage returns). |
\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 are no matches in "book" |
\d |
Any numeric character. equivalent to [0-9]. |
\d matches "2" in "3" and "Apartment 2G" in "C3PO" |
\d |
Any non-numeric character. is equivalent to [^0-9]. |
\d matches "Q" in "S" and "Q45" in "900S" |
\f |
Page breaks. |
|
\ n |
Line feed. |
|
\ r |
The carriage return character. |
|
\s |
Any single whitespace character, including spaces, tabs, page breaks, or line breaks. |
\sbook matches "book" in "Blue Book", but there are no matches in "notebook" |
\s |
Any single non-white-space character. |
\sbook matches "book" In "Notebook", but there are no matches in "Blue Book" |
\ t |
Tabs. |
|
\w |
Any alphanumeric characters, including underscores. 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. is equivalent to [^a-za-z0-9_]. |
\w matches the "Jake&mattie" in the |