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('|abc([a-z]+)g|isu',$a,$out1); preg_match_all('|abc([s]+)g|isu',$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('|href="(.*)"|isu',$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!