ホームページ  >  記事  >  バックエンド開発  >  求一正则匹配解决思路

求一正则匹配解决思路

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 までご連絡ください。