Get the App
SLTechnology News&Howtos  ›  Development  › 

What do I, m, s, x and e denote in php regularity

Shulou Source: shulou.com Published: 2022-06-03 19:49:39 11月12日 Update

This article mainly explains "what do I, m, s, x, e in php rules represent?" the content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what do I, m, s, x, e in php rules represent respectively?"

I

If you set this modifier, the characters in the pattern will match both uppercase and lowercase letters.

M

When this modifier is set, Line start and Line end match not only the beginning and end of the entire string, but also after and before the newline character, respectively.

S

If this modifier is set, the dot metacharacter (.) in the pattern matches all characters, including newline characters. Without this setting, newline characters are not included.

X

If this modifier is set, the white space characters in the pattern are completely ignored except those that are escaped or in the character class, and all characters between # and the next newline character, including both ends, outside the unescaped character class.

E

If this modifier is set, preg_replace () replaces the reverse reference normally in the replacement string

? In. + and * indicate a non-greedy match: *, + and? Qualifiers are greedy because they match as many words as possible, only adding one after them. Non-greedy or minimal matching can be achieved.

For example:

Example: (? I):

(? I) in PHP means internal corrector, and I means case-insensitive

Other modifiers include xrem, mrem, s, U and so on. It's the same as the pattern modifier we use.

The difference is that it is used internally in the pattern. Works only in the submode in which (? I) is located

Such as

Ccc (a (? I)) bcd matches cccabcd and cccAbcd

And a (? I) bc is the same as abc plus the\ I modifier because (? I) acts on the whole pattern.

Backward reference

Adding parentheses to both sides of a regular expression pattern or partial pattern causes related matches to be stored in a temporary buffer, with each captured submatch stored according to what is encountered from left to right in the regular expression pattern. The buffer number of the storage sub-match starts at 1 and is numbered up to a maximum of 99 subexpressions. Each buffer can be accessed using'\ n', where n is an one-or two-digit decimal number that identifies a particular buffer.

You can use non-capture metacharacters'?:','? =', or'?!' To ignore the saving of related matches.

Thank you for your reading, the above is the content of "what I, m, s, x, e represent respectively in php rule". After the study of this article, I believe you have a more profound understanding of what I, m, s, x, e represent in php rule, and the specific use still needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Pattern character regular content newline character buffer buffer greed expression storage learning size function metacharacter size string escape minimum between two ends Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi MariaDB Linux macOS vpn