<?php /** * Created by PhpStorm. * User: Ollydebug * Date: 2015/11/15 * Time: 15:20 */ $pattern = '/google.+123/'; //$pattern = '/google.+123/'; 修正匹配 //$pattern = '/google.+123/U'; 懒惰匹配 $subject = 'I love google__123123123123123123'; $matches = array(); preg_match($pattern,$subject,$matches); show($matches); function show($var){ if(empty($var)){ echo 'null'; }elseif(is_array($var)||is_object($var)){ // array,object echo '<pre class="brush:php;toolbar:false">'; print_r($var); echo ''; }else{ //string,int,float echo $var; } } ?>
以上就是(PHP)正则表达式-贪婪匹配与懒惰匹配的区别的内容,更多相关内容请关注PHP中文网(www.php.cn)!