我想用PHP正则把
[email protected]
用正则匹配出来 成为
aaaa bbbb qqqq com我用split('\w+',"[email protected]")
这样匹配失败
难道是我正则写错了吗?还是有其他问题 ,请各位指教一下 谢谢了。

解决方案 »

  1.   


    <?php
    $str = '[email protected]';
    print_r(preg_split('/@|\./', $str));
    ?>
      

  2.   

    preg_match_all('\w+',"[email protected]", $r);
    print_r($r[0]);
      

  3.   

    echo strtr("[email protected]", array('@'=>' ','.'=>' '));
      

  4.   

    echo str_replace(array('@','.'), ' ', $s);
      

  5.   

    $str = "[email protected]";
    $result = preg_split("/(@|\.)/i" , $str);  // 按满足正则表达式的部分进行拆分~
      

  6.   

    你理解错误
    preg_split 里面的正则是指示分割的符号,而不是分割后获得的部分