时间:2021-07-01 10:21:17 帮助过:25人阅读
通常我们会这么写:
$str = "http://www.baidu/.com?url=www.sina.com/";preg_match("/http:(.*)com/", $str, $matches);print_r($matches);
Array ( [0] => http://www.baidu/.com?url=www.sina.com [1] => //www.baidu/.com?url=www.sina. )
$str = "
结果:
Array ( [0] => http://www.baidu/.com [1] => //www.baidu/. )
简单的说只要在一个字符后面跟上限定个数的特殊字符,匹配就是非贪婪模式了。小伙伴们是否理解了呢?
版权声明:本文为博主原创文章,未经博主允许不得转载。