首頁  >  文章  >  後端開發  >  求一正则匹配解决思路

求一正则匹配解决思路

WBOY
WBOY原創
2016-06-13 11:48:45815瀏覽

求一正则匹配
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

把13,15,18开头的踢出去
求正则
------解决方案--------------------

$s=<<<html<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />html;<br />preg_match_all('/^(?!13<br><font color='#FF8000'>------解决方案--------------------</font><br>15<br><font color='#FF8000'>------解决方案--------------------</font><br>18).+/m',$s,$m);<br />print_r($m);

------解决方案--------------------
$s =<<< TXT<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />TXT;<br /><br />//方案一<br />preg_match_all('/^(?!13<br><font color='#FF8000'>------解决方案--------------------</font><br>15<br><font color='#FF8000'>------解决方案--------------------</font><br>18).*/m', $s, $r);<br />print_r($r);<br /><br />//方案二<br />echo preg_replace('/^(13<br><font color='#FF8000'>------解决方案--------------------</font><br>15<br><font color='#FF8000'>------解决方案--------------------</font><br>18).*?/m', '', $s);<br />
Array<br />(<br />    [0] => Array<br />        (<br />            [0] => [email&#160;protected]<br />            [1] => [email&#160;protected]<br />            [2] => [email&#160;protected]<br />            [3] => [email&#160;protected]<br />            [4] => [email&#160;protected]<br />            [5] => [email&#160;protected]<br />            [6] => [email&#160;protected]<br />        )<br /><br />)<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />[email&#160;protected]<br />

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn