Heim > Artikel > Backend-Entwicklung > 求一正则匹配解决思路
求一正则匹配
[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 protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email 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 protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email 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 protected]<br /> [1] => [email protected]<br /> [2] => [email protected]<br /> [3] => [email protected]<br /> [4] => [email protected]<br /> [5] => [email protected]<br /> [6] => [email protected]<br /> )<br /><br />)<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />[email protected]<br />