The metacharacter in regular expression:(自己总结的,可能不全)
Metacharacter | Description |
? | (1)The preceding item is optional and will be matched, at most, once. |
+ | The preceding item will be matched one or more times. |
* | The preceding item will be matched zero or more times. |
( | make subexpressions or to put boundaries on parts of expressions |
) | |
. | Matches any single character |
| | logical OR(也就是正则表达式中的或操作) |
^ |
(1)represents the characters not in the range of a list.
(2)the start of input text
|
/ | escape character(转义符) |
[ | define your own character classes using the notation [...]. |
] | |
{ | define the Range Interval for matching |
} | |
$ | the end of text |
&& | logical AND |
Note: (节选自网页:)
Operator Effect
. Matches any single character.
? The preceding item is optional and will be matched, at most, once.
* The preceding item will be matched zero or more times.
+ The preceding item will be matched one or more times.
{N} The preceding item is matched exactly N times.
{N,} The preceding item is matched N or more times.
{N,M} The preceding item is matched at least N times, but not more than M times.
- represents the range if it's not first or last in a list or the ending point of a range in a list.
^ Matches the empty string at the beginning of a line; also represents the characters not in the range of a list.
$ Matches the empty string at the end of a line.
/b Matches the empty string at the edge of a word.
/B Matches the empty string provided it's not at the edge of a word.
/< Match the empty string at the beginning of word.
/> Match the empty string at the end of word.
. Matches any single character.
? The preceding item is optional and will be matched, at most, once.
* The preceding item will be matched zero or more times.
+ The preceding item will be matched one or more times.
{N} The preceding item is matched exactly N times.
{N,} The preceding item is matched N or more times.
{N,M} The preceding item is matched at least N times, but not more than M times.
- represents the range if it's not first or last in a list or the ending point of a range in a list.
^ Matches the empty string at the beginning of a line; also represents the characters not in the range of a list.
$ Matches the empty string at the end of a line.
/b Matches the empty string at the edge of a word.
/B Matches the empty string provided it's not at the edge of a word.
/< Match the empty string at the beginning of word.
/> Match the empty string at the end of word.
Two regular expressions may be concatenated; the resulting regular expression matches any string formed by concatenating two substrings that respectively match the concatenated subexpressions.
Two regular expressions may be joined by the infix operator "|" ; the resulting regular expression matches any string matching either subexpression.
Repetition takes precedence over concatenation, which in turn takes precedence over alternation. A whole subexpression may be enclosed in parentheses to override these precedence rules.