Rumah  >  Artikel  >  pembangunan bahagian belakang  >  求一正则匹配解决思路

求一正则匹配解决思路

WBOY
WBOYasal
2016-06-13 11:48:45817semak imbas

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

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn