当前位置:Gxlcms > PHP教程 > 再正则

再正则

时间:2021-07-01 10:21:17 帮助过:24人阅读

再求一个正则
比如我有......(略)
...(略)
....(略)

......(略)
‎(105)





我只要其中 class=cnt 的span,并且只要105这个数字;请问该如何写?

------解决方案--------------------
得到 数组 foo 之后做个判断,万一没有匹配内容的话直接输出会有出错提示.
PHP code

$str = '‎(105)';
preg_match ( '/.*\(([\d]+)\)/', $str, $foo );
$bar=isset ($foo[1])? $foo[1]:'';
echo $bar;                     

人气教程排行