Home  >  Article  >  Backend Development  >  求一正则匹配解决思路

求一正则匹配解决思路

WBOY
WBOYOriginal
2016-06-13 11:48:45817browse

求一正则匹配
[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 />

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