Home  >  Article  >  Backend Development  >  What does isU of preg_match in php mean?

What does isU of preg_match in php mean?

怪我咯
怪我咯Original
2017-07-12 15:37:471542browse

i: means in-casesensitive, that is, case-insensitive
s: PCRE_DOTALL, means that the dot can match newline characters.
U: means PCRE_UNGREEDY, which means non-greedy, equivalent to .*? in perl/python language. During the matching process, for .* regular rules, they will be executed immediately as soon as there is a match, instead of waiting.* All characters are consumed and then rolled back one by one.

Example

preg_match compatibleRegular expressionIn the syntax, b represents the word boundary

So: The following should be OK? ? ?

$a="test,admin,abc";
$b="te";
$exist=preg_match("/b{$b}b/",$a);
if($exist)
{
echo "存在";
}else
{
echo "不存在";
}

Look at the relevant instructions

The code is as follows:

int preg_match ( string pattern, string subject [, array matches [, int flags]] );

preg_match() returns the number of times pattern is matched. Either 0 times (no match) or 1 time, since preg_match() will stop searching after the first match. preg_match_all(), on the contrary, will search until the end of subject. preg_match() returns false on error.

Example:

<?php
$a = "abcdefgabcdefaaag";
preg_match(&#39;|abc([a-z]+)g|isu&#39;,$a,$out1);
preg_match_all(&#39;|abc([s]+)g|isu&#39;,$a,$out2);
echo "<pre class="brush:php;toolbar:false">";
print_r($out1);
print_r($out2);
echo "
"; ?>

Writing:

The difference between using double quotes and single quotes

<?php
preg_match_all("/href="(.*)"/isu",$contents,$out);
preg_match_all(&#39;|href="(.*)"|isu&#39;,$contents,$out);
?>

The above is the detailed content of What does isU of preg_match in php mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn