php100学习记录38

下面是两个学习代码,点击下载

<?php
$pattern="/<(.*)>/U";
$subject="<b>sssss</b>dsd"; //这样即可匹配到<b>
//不加U则匹配到<b>sssss</b>
 
if(preg_match($pattern,$subject,$arr)){
	echo "success"."".$arr[0];
}else{
	echo "failure";
}
?>
$pattern="/abc/i";
$subject="cdfgsfABC"; 
 
$pattern="/^abc/m";
$subject="dsdabdscdsd\nabcsdsdad"; 
 
$pattern="/goog(.*)yahoo/s";
$subject="google\nbaidu\nyahoo"; 
 
$pattern="/\d{2,4}(.*)\d{1,2}\\1 15/x";//x作用去掉\\1 15之间的空白
$subject="2009-09-15"; 
 
$pattern="/^google/A";
$subject="baidu\ngoogle"; //这样是失败的
// $subject="googlebaidu\ngoogle"; //这样是成功的
 
$pattern="/du$/D";
$subject="baidu\ngoogle"; //这样是失败的
//这样是成功的  $subject="baidu\ngoogledu";
 
$pattern="/<(.*)>/U";
$subject="<b>sssss</b>dsd"; //这样即可匹配到<b>
//不加U则匹配到<b>sssss</b>

Related posts:

Leave a Reply

Your email address will not be published.