This article mainly introduces the meaning of isU of preg_match in php. Interested friends can refer to it. I hope it will be helpful to everyone.
isU means case separation, s here does not include the newline character, and U reverses the value of the number of matches so that it is not a default repetition. This is probably the case when we read the article.
/(.*)/isU after the regular expression, what does the "isU" parameter mean?
This is the modifier in the regular expression.
i searches for both uppercase and lowercase letters, and
s is a dot (.) that matches all characters, including newlines. If If s is not set, the newline character is not included.
U reverses the value of the number of matches so that it is not repeated by default, but becomes repeated when followed by "?"
Example
preg_match In the compatible regular expression syntax, b represents the word boundary
So: The following should be possible? ? ?
$a="test,admin,abc"; $b="te"; $exist=preg_match("/b{$b}b/",$a); if($exist) { echo "存在"; }else { echo "不存在"; }
Look at the relevant instructions
Copy code 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); ?>
Summary: The above is the text The entire content of this article is hoped to be helpful to everyone's study.
Related recommendations:
The function of ZipArchive function in php
php implements batch processing to detect whether the page has been Functions included in Baidu
Calendar program implemented in php
The above is the detailed content of What does isU of preg_match in php represent?. For more information, please follow other related articles on the PHP Chinese website!