h">
浅谈php正则表达式中的非贪婪模式匹配的使用
php  /  管理员 发布于 7年前   200
通常我们会这么写: 结果: 非贪婪模式匹配: 结果: 简单的说只要在一个字符后面跟上限定个数的特殊字符,匹配就是非贪婪模式了。小伙伴们是否理解了呢? 122 在 123 在 原梓番博客 在 博主 在 1111 在
$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 = "http://www.baidu/.com?url=www.sina.com/";
preg_match("/http:(.*?)com/", $str, $matches);
print_r($matches);
Array ( [0] => http://www.baidu/.com [1] => //www.baidu/. )您可能感兴趣的文章:
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号