php100学习记录37

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

<?php
$pattern="/\d{2,4}(.*)\d{1,2}(.*)\d{1,2}/";
$subject="2009-09-15"; //$subject="2009/09/15";
 
 
if(preg_match($pattern,$subject,$arr)){
	echo "success"."<br>".$arr[0];
}else{
	echo "failure";
}
?>
 $pattern="/go*gle/";
$subject="google";
 
$pattern="/go.gle/";
 $subject="gozgle";
 
 $pattern="/go+gle/";
$subject="gooooogle";
 
$pattern="/go?gle/";
$subject="gogle";
 
$pattern="/baidu|google/";
$subject="asdgooglesds";
 
$pattern="/^google/";
$subject="googlesadasd";
 
$pattern="/google$/";
$subject="sadasdgoogle";
 
$pattern="/\bis\b/";
$subject="what-is this";
 
$pattern="/\Bis/";
$subject="what is this";
 
$pattern="/goog{3}le/";
$subject="what is ggoogggle"; //注意这个
 
$pattern="/goog{3,}le/";
$subject="what is ggooggggle";
 
$pattern="/goog{3,6}le/";
$subject="what is ggooggggle";
 
$pattern="/goo(abc)gl\\1e/";
$subject="gooabcglabce"; 
 
$pattern="2009(.*)09(.*)(15)";
$subject="2009-09-15"; //$subject="2009/09/15";
 
 
$pattern="/\d{2,4}(.*)\d{1,2}(.*)\d{1,2}/";
$subject="2009-09-15"; //$subject="2009/09/15";

Related posts:

Leave a Reply

Your email address will not be published.