On the problem of preg_replace function _ Regular expression

Source: Internet
Author: User
I would like to ask the next sentence the role of this statement. Explain it to me. "," E "," I "," s ", what the symbols mean, and what they do. Is there any other mode besides "/eis"?
If there are related to the study material can give me? Thanks, everybody's help! Thank you.

$post =preg_replace ("/\[html\]" (. +?) \[\/html\]/eis "," Htmlcode (' \\1 ') ", $post);
Modifiers:
Modifiers inside regular expressions can change many of the regular features, making regular expressions more appropriate for your needs (note: Modifiers are sensitive to capitalization, which means "E" is not equal to "E"). The modifiers in the regular expression are as follows:
I: If you add "I" to the modifier, it will remove the case sensitivity, that is, "a" and "a" are the same.
M: The default regular start "^" and end "$" just for regular strings if you add "M" to the modifier, the start and end will refer to each line of the string: "^" at the beginning of each line, and "$" at the end.
S: If you add "s" to the modifier, the default "." Any character that represents anything other than a line break will become any character, including a newline character!
X: If you add the modifier, the white space character in the expression will be ignored unless it has been escaped.
E: This modifier is only useful for replacement, and represents the PHP code in replacement.
A: If you use this modifier, the expression must be the beginning of the matching string. For example, "/a/a" matches "ABCD".
E: In contrast to "M", if this modifier is used, then "$" matches the end of the absolute string, rather than the newline character, which is turned on by default.
U: Similar to the question mark, used to set "greedy mode."

? Forms are not greedy matches, that is, as few matches as possible
And
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
The middle of the content
E means that a function can be used to handle the child-matching part of the backward primer
I table is not case insensitive,
S says. Also matches line breaks
Suppose you have the following string
This is a text
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
This is another text
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Use/\[html\] (. +?) The results of \[\/html\]/and using [Html\] (. +) \[\/html\]/u are the same,
is not greedy, but one with the modifier, one with the grammar.
The result is
This is a text
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
And
This is another text
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Two matches,
And the result of/\[html\] (. +) \[\/html\]/is
This is a text
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
This is another text
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
A match
Because the entire character is also consistent with the "
"Start with"
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
"At the end, just to get more strings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.