当前位置: 代码迷 >> PHP >> 求1正则匹配
  详细解决方案

求1正则匹配

热度:78   发布时间:2016-04-28 20:00:27.0
求一正则匹配
[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
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
html;
preg_match_all('/^(?!13
------解决方案--------------------
15
------解决方案--------------------
18).+/m',$s,$m);
print_r($m);

------解决方案--------------------
$s =<<< TXT
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
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] => [email protected]
            [1] => [email protected]
            [2] => [email protected]
            [3] => [email protected]
            [4] => [email protected]
            [5] => [email protected]
            [6] => [email protected]
        )

)
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
  相关解决方案