| Home | Misc | Run Code | Code Wall | Users | Feedback | Login |
| Character | Definition | Example |
|
Most characters |
Characters other than . $ ^ { [ ( | ) * + ? \ match themselves. If you need to match these special characters - precede them by \ |
abc matches abc \? matches ? |
|
^ |
The pattern has to appear at the beginning of a string. | ^cat matches any string that begins with cat |
|
$ |
The pattern has to appear at the end of a string. | cat$ matches any string that ends with cat |
|
. |
Matches any character. | cat. matches catT and cat2 but not catty |
|
[] |
Bracket expression. Matches one of any characters enclosed. | gr[ae]y matches gray or grey |
|
[^] |
Negates a bracket expression. Matches one of any characters EXCEPT those enclosed. | 1[^02] matches 13 but not 10 or 12 |
|
[-] |
Range. Matches any characters within the range. | [1-9] matches any single digit EXCEPT 0 |
|
? |
Preceeding item must match one or zero times. | colou?r matches color or colour but not colouur |
|
+ |
Preceeding item must match one or more times. | be+ matches be or bee but not b |
|
* |
Preceeding item must match zero or more times. | be* matches b or be or beeeeeeeeee |
|
() |
Parentheses. Creates a substring or item that metacharacters can be applied to | a(bee)?t matches at or abeet but not abet |
|
{n} |
Bound. Specifies exact number of times for the preceeding item to match. | [0-9]{3} matches any three digits |
|
{n,} |
Bound. Specifies minimum number of times for the preceeding item to match. | [0-9]{3,} matches any three or more digits |
|
{n,m} |
Bound. Specifies minimum and maximum number of times for the preceeding item to match. | [0-9]{3,5} matches any three, four, or five digits |
|
| |
Alternation. One of the alternatives has to match. | July (first|1st|1) will match July 1st but not July 2 |
|
\n |
The newline character. (ASCII 10) | \n matches a newline |
|
\s |
A single whitespace character. | a\sb matches a b but not ab |
|
\d |
A single digit character. | a\db matches a2b but not acb |