PHP extension text processing -- PCRE regular expression syntax 2 -- the power of metacharacters regular expression is that it can have the ability to select and repeat in the mode. Some characters are given special meanings, so that they do not simply represent themselves. in the mode, such encoded characters with special meanings are called metacharacters.
There are two different metacharacters: one can be used anywhere outside the Chinese brackets of the pattern, and the other must be used in square brackets. The metacharacters used outside Square brackets are as follows:
\
It is generally used to escape characters.
^
The start position of the assertion target (or the first row in multi-row mode)
$
The end position of the assertion target (or the end of the row in multi-row mode)
.
Match any character except linefeed (default)
[
Start character class definition
]
End character class definition
|
Start an optional branch
(
Start tag of the sub-group
)
End tag of the sub-group
?
As a quantizer, it indicates 0 or 1 match. It is behind the quantifiers to change the greedy nature of quantifiers.
*
Quantifiers, 0 or multiple matches
+
Quantifiers, matching once or multiple times
{
Start marking of custom quantifiers
}
Custom quantifiers end mark
The section in the square brackets of the pattern is called "character class ". Only the following metacharacters are available in a character class:
\
Escape characters
^
If it is used only as the first character (inside square brackets), it indicates that the character class is reversed.
-
Mark character range