Home  >  Article  >  Backend Development  >  求解一个php正则表达式的组合,该如何解决

求解一个php正则表达式的组合,该如何解决

WBOY
WBOYOriginal
2016-06-13 13:34:26935browse

求解一个php正则表达式的组合
(.*?) 这个匹配是是任意多个字符 为什么不直接(*?)

------解决方案--------------------
你是想说为什么不用“.*”吧?
看下面例子:

PHP code

$str = 'aabab';
$pattern1 = '/a.*b/';    //匹配出aabab
$pattern2 = '/a.*?b/';   //匹配出aab <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn