PHP extension text processing-the PCRE regular expression pattern modifier lists currently available PCRE modifiers. The names mentioned in brackets are the names of these modifiers in PCRE. Space in the pattern modifier. line breaks are ignored. other characters may cause errors.
I (PCRE_CASELESS)
If this modifier is set, the letters in the mode are case-insensitive.
M (PCRE_MULTILINE)
By default, PCRE considers the target string to be composed of single-line characters (however, it may actually contain multiple lines) and "first line" metacharacters (^) only match the start position of the string, while the metacharacter ($) at the end of the line matches only the end of the string or the last line break (unless the D modifier is set ). This behavior is the same as perl. After this modifier is set, "first line" and "last line" match any line break in the target string before or after. In addition, it also matches the start and end positions of the target string respectively. This is equivalent to the/m modifier of perl. If the target string does not contain the "\ n" character, or the "^" or "$" character does not appear in the mode, setting this modifier will not affect you.
S (PCRE_DOTALL)
If this modifier is set, the DOT metacharacters in the mode match all characters, including line breaks. If this modifier does not exist, the dot does not match the linefeed. This modifier is equivalent to the/s modifier in perl. An anti-character class such as [^ a] always matches a line break, and does not rely on the modifier settings.
X (PCRE_EXTENDED)
If this modifier is set, blank data characters in the mode that are not escaped or not in the character class are always ignored, in addition, the characters between the # character and the next line break located outside of an unescaped character class are also ignored. This modifier is equivalent to the/x modifier in perl, so that the compiled mode can contain comments. Note: this is only used for data characters. Blank characters cannot appear in a special character sequence in the mode, such as a sequence (? (A condition sub-group is introduced. if there is a blank character in the special character sequence defined by the syntax, compilation errors may occur. For example (? (It will cause an error ).
E (PREG_REPLACE_EVAL)
If this modifier is set, preg_replace () will evaluate and execute the replaced string as php code (eval function mode) after the replacement string is replaced by a reference ), and use the execution result as the string to be replaced. Single quotation marks, double quotation marks, backslash (\), and NULL characters are escaped by backslash when being replaced by backward references.
Note: Make sure that the replacement parameter is composed of valid php code strings. otherwise, php will generate an interpretation error on the row called by preg_replace. Only preg_replace () uses this modifier, which is ignored by other PCRE functions.
A (PCRE_ANCHORED)
If this modifier is set, the pattern is forced to "anchored", that is, the constraint match enables it to search only from the starting position of the target string. This effect can also be constructed using the appropriate mode, and this is also the only way for perl to implement this mode.
D (PCRE_DOLLAR_ENDONLY)
If this modifier is set, the dollar sign in the schema matches only the end of the target string. If this modifier is not set, when the string ends with a linefeed, the dollar symbol will match the linefeed (but will not match any previous linefeeds ). If the modifier m is set, this modifier is ignored. there is no modifier equivalent to this modifier in perl.
S
When a mode needs to be used multiple times, it is worthwhile to spend some time to analyze it to improve the matching speed. If this modifier is set, this additional analysis will be executed. Currently, this analysis of a pattern is only applicable to non-anchoring pattern matching (that is, there is no separate fixed start character ).
U (PCRE_UNGREEDY)
This modifier reverses the "greedy" pattern of quantifiers. The quantifiers are non-greedy by default, followed by quantifiers? To make it greedy. This is incompatible with perl. It can also be set using the in-mode modifier (? U), or mark it with a question mark (such as. *?) after the quantifiers .*?).
Note: In non-greedy mode, it is generally not allowed to match characters that exceed pcre. backtrack_limit.
X (PCRE_EXTRA)
This modifier enables the Attachment feature that is not compatible with perl. After any backslash in the mode, a character with no special meaning will cause an error, so as to retain these characters to ensure backward compatibility. By default, in perl, the backslash is followed by a character without special meaning and is considered as the original character of the character. Currently, no other features are controlled by this modifier.
J (PCRE_INFO_JCHANGED)
Set internal options (? J) modify the local PCRE_DUPNAMES option. Allow sub-groups to have multiple names .)
U (PCRE_UTF8)
This modifier opens an additional feature that is incompatible with perl. The pattern string is considered to be UTF-8. This modifier is available for php 4.1.0 or later in unix and php 4.2.3 In win32. Php 4.3.5 starts to check the validity of the UTF-8 mode.