<?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)!