About
There are two different sets of meta-characters:
- those that are recognized anywhere in the pattern except within square brackets,
- and those that are recognized in square brackets.
Articles Related
Square brackets
Outside
| Operator | Description | Example |
|---|---|---|
| Escape | ||
| \ | general escape character with several uses. It can: * Stand for itself, * Quote the next character, * Introduce an operator, * Do nothing | |
| Quantifier | ||
| * | Matches 0 or more occurrences of the preceding element | ab*c matches “ac”, “abc”, “abbc”, “abbbc”, and so on |
| + | Matches 1 or more occurrences of the preceding element | ab+c matches “abc”, “abbc”, “abbbc”, and so on, but not “ac” |
| ? | Matches 0 or 1 occurrence of the preceding element | colou?r matches both “color” and “colour” |
| { | start min/max quantifier | |
| } | end min/max quantifier | |
| {m} | Matches exactly m times | |
| {m,} | Matches at least m times | |
| {m,n} | Matches at least m times but no more than n times | |
| Boundary | ||
| ^ | Matches the beginning of a string by default. (or line, in multiline mode) | |
| $ | Matches the end of a string by default. (or line, in multiline mode) | [hc]at$ matches “hat” and “cat”, but only at the end of the string or line. |
| Logical Matcher | ||
| | | Boolean “or” - start of alternative branch to specify alternative matches | gray|grey can match “gray” or “grey” |
| Character | ||
| . | dot Matches any character in the supported character set except NULL | .at matches any three-character string ending with “at”, including “hat”, “cat”, and “bat”. Dot may not match newlines, option is required |
| Character Class | ||
| [ | start character class definition | |
| ] | end character class definition | |
| Grouping | ||
| ( | start subpattern | See grouping expression |
| ) | end subpattern | See grouping expression |
| ( ) | Grouping expression, treated as a single subpattern | gray|grey and gr(a|e)y are equivalent patterns which both describe the set of “gray” and “grey” |
| Greedy Lazy matching | ||
| ? | Regular Expression - (Lazy|Reluctant) Quantifier | |
Inside
See Meta in class
