久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網
      最全最豐富的資訊網站

      PHP preg match正則表達式函數的操作實例

      在php中preg_match()函數是用來執(zhí)行正則表達式的一個常用的函數。正則表達式幾乎在所有編程語言里面都會用到,本實例介紹php中正則表達式preg_match函數的應用。

      preg_match() 函數用于進行正則表達式匹配,成功返回 1 ,否則返回 0 。

      preg_match() 匹配成功一次后就會停止匹配,如果要實現全部結果的匹配,則需使用 preg_match_all() 函數。

      語法:

        preg_match (pattern , subject, matches)

      參數 描述
      pattern 正則表達式
      subject 需要匹配檢索的對象
      matches 可選,存儲匹配結果的數組

      實例:

      此實例匹配大寫字母后面帶有.和空格的字符串,只能匹配到J. ,因為preg_match() 匹配成功一次后就會停止匹配,后面不會再匹配了。

        <?php  $str="Daniel J. Gross Catholic High School A. is a faith and family based community committed to developing Christian leaders through educational excellence in the Marianist tradition.";  if(preg_match("/[A-Z]. /",$str,$matches)){  print_r($matches);  }  ?>

      輸出結果:

      Array ( [0] => J. )

      下面給大家介紹preg_match字符串長度問題

      preg_match正則提取目標內容,死活有問題,代碼測得死去活來。

      后來懷疑PHP 的preg_match有字符串長度限制,果然,發(fā)現“pcre.backtrack_limit ”的值默認只設了100000。

      解決辦法:

        ini_set('pcre.backtrack_limit', 999999999);

      注:這個參數在php 5.2.0版本之后可用。

      另外說說關于:pcre.recursion_limit

      pcre.recursion_limit是PCRE的遞歸限制,這個項如果設很大的值,會消耗所有進程的可用堆棧,最后導致PHP崩潰。

      也可以通過修改配置來限制:

      ini_set(‘pcre.recursion_limit’, 99999);

      實際項目應用中,最好也對內存進行限定設置:ini_set(‘memory_limit’, ’64M’); , 這樣就比較穩(wěn)妥妥嘎。

      贊(0)
      分享到: 更多 (0)
      網站地圖   滬ICP備18035694號-2    滬公網安備31011702889846號