PHP正则表达式如何写?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP正则表达式如何写?相关的知识,希望对你有一定的参考价值。
昵称正则var reg=/^[\\u4E00-\\u9FA5A-Za-z0-9]2,10$/;文本域:var reg=/^[^<>#$%/]1,140$/;
邮箱:var reg=/^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$/;
preg_match(reg, $banknumber)
preg_match("/^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17([0-3]|[5-9]))|(18[0,5-9]))\\\\d8$/",\'17755332020\')//最新手机号 参考技术A $a=1;$b=2;
$c=$a>$b?$a:$b;
php如何使用正则表达式匹配url图片啊
参考技术A // 抓取网页echo "\\n\\n抓取网页=======================================\\n";
function getHTTPS($url)
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt ( $ch, CURLOPT_HEADER, false );
curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt ( $ch, CURLOPT_REFERER, $url );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, TRUE );
$result = curl_exec ( $ch );
curl_close ( $ch );
return $result;
$result = getHTTPS ( "" );
$array = array (
'img',
'script',
'link'
);
$num = count ( $array );
for($i = 0; $i < $num; ++ $i)
echo $array [$i] . "--------------------------------\\n";
if (preg_match_all ( "/<" . $array [$i] . "[^>]*>/i", $result, $m ))
for($j = 0; $j < count ( $m [0] ); $j ++)
echo $m [0] [$j] . "\\n";
参考技术B /<img(.*)? src=["|'](.*)["|'](.*)?>/Uis
以上是关于PHP正则表达式如何写?的主要内容,如果未能解决你的问题,请参考以下文章