After the end separator, you can follow multiple pattern modifiers (called patternmodifier in php). In some cases, modifiers can also appear in regular expressions, modifies certain properties of a pattern. We have seen in some examples the case-insensitive mode... SyntaxHighlighter. all ();
After the separator ends, you can follow multiple pattern modifiers (called pattern modifier in php ),
In some cases, modifiers can also appear inside regular expressions to modify certain properties of the pattern. We have seen in some examples that I is a case-insensitive pattern modifier. The pattern modifier is described below:
|
Modifier |
Writing in expressions |
Description |
|
I |
(? I) |
Ignore case sensitivity |
|
M |
(? M) |
Enhanced line anchor mode |
|
S |
(? S) |
Ø point/number wildcard mode |
|
X |
(? X) |
Ø loose arrangement and comment mode |
|
U |
|
Reading regular expressions and target strings with UTF-8 |
|
X |
(? X) |
Enable "extra stuff" for PCRE )" |
|
E |
|
Ø use replacement as PHP code (for preg_replace only) |
|
S |
|
Enable "study" Optimization of PCRE |
|
The following three are rarely used. |
|
U |
(? U) |
Exchange "*" and "*? Matching priority |
|
A |
|
Ø pin the entire matching attempt at the starting position |
|
D |
|
Ø "$1" can only match with EOS, not the line break before EOS
(This is not the case if the pattern modifier m is used) |
Pattern modifier inside the expression
In a regular expression, a pattern modifier can appear independently to enable or disable certain features (for example "(? I) "to enable case-insensitive matching, use "(? -I. At this time, their scope of action continues to the end brackets. if they do not exist, they continue to the end of the regular expression.
They can also be used as pattern modifier ranges such "(? I...) "indicates that the content in the brackets is case-insensitive "(? -Sm:...) "indicates that s and m modes are disabled in this range.
In addition to regular expressions, the pattern modifiers after the ending separator can be organized in any order. in the following example, 'Si' indicates that the case-insensitive and point-number wildcard modes are enabled simultaneously:
If (preg_match ('{(.*?)} Si', $ html, captures ))
From lostwolf's Blog