日期:2014-05-17  浏览次数:20590 次

正则如何同时匹配两种模式
我不知道怎么表达清楚我的意思,举个例子
PHP code
$content = "xxxhttp://xxx.com/hello.htmlxxx";
preg_match_all( "/http:\/\/xxx\.com\/[\w|']{4,17}\.html/iUs", $content, $result);
// 将会得到结果 
array(
[0] => array(
    [0] => http://xxx.com/hello.html
    )
)


我想同时得到表达式代表的 hello 该怎么做?

------解决方案--------------------
实际操作楼上已经写了

我提供两个参考链接
http://deerchao.net/tutorials/regex/regex.htm
这个是我查正则写法的参考文档

http://cn.php.net/manual/zh/reference.pcre.pattern.syntax.php
这个是php使用的pcre正则的参考手册
------解决方案--------------------
楼主没有把正则练习熟悉,需要把正则各个符号的意思,弄清楚,那么就不难了.