日期:2014-05-16  浏览次数:20507 次

求一正则匹配
2755913@qq.com
531747329@qq.com
18272405405@qq.com
15926350668@qq.com
15090705673@qq.com
419373376@qq.com
451510003@qq.com
1310865177@qq.com
303568545@qq.com
173460678@qq.com
dsaasd@qq.com

把13,15,18开头的踢出去
求正则

------解决方案--------------------
$s=<<<html
2755913@qq.com
531747329@qq.com
18272405405@qq.com
15926350668@qq.com
15090705673@qq.com
419373376@qq.com
451510003@qq.com
1310865177@qq.com
303568545@qq.com
173460678@qq.com
dsaasd@qq.com
html;
preg_match_all('/^(?!13
------解决方案--------------------
15
------解决方案--------------------
18).+/m',$s,$m);
print_r($m);

------解决方案--------------------
$s =<<< TXT
2755913@qq.com
531747329@qq.com
18272405405@qq.com
15926350668@qq.com
15090705673@qq.com
419373376@qq.com
451510003@qq.com
1310865177@qq.com
303568545@qq.com
173460678@qq.com
dsaasd@qq.com
TXT;

//方案一
preg_match_all('/^(?!13
------解决方案--------------------
15
------解决方案--------------------
18).*/m', $s, $r);
print_r($r);

//方案二
echo preg_replace('/^(13
------解决方案--------------------
15
------解决方案--------------------
18).*?/m', '', $s);
Array
(
    [0] => Array
        (
            [0] => 2755913@qq.com
            [1] => 531747329@qq.com
            [2] => 419373376@qq.com
            [3] => 451510003@qq.com
            [4] => 303568545@qq.com
            [5] => 173460678@qq.com
            [6] => dsaasd@qq.com
        )

)
2755913@qq.com
531747329@qq.com
272405405@qq.com
926350668@qq.com
090705673@qq.com
419373376@qq.com
451510003@qq.com
10865177@qq.com
303568545@qq.com
173460678@qq.com
dsaasd@qq.com