如题,求帮写一个正则,如下:
匹配中文/英文/特殊字符,不匹配HTML标签
谢谢啦

解决方案 »

  1.   

    给出一段测试文本,再给出一段匹配到的文本若只是不匹配 html 标签,可以直接用 strip_tags 方法去除html标签
      

  2.   

    strip_tags — 从字符串中去除 HTML 和 PHP 标记正则学习 : http://www.source-open.com/478222
      

  3.   


    function html2txt($document){ 
    $search = array('@<script[^>]*?>.*?</script>@si',  // Strip out javascript 
                   '@<[\/\!]*?[^<>]*?>@si',            // Strip out HTML tags 
                   '@<style[^>]*?>.*?</style>@siU',    // Strip style tags properly 
                   '@<![\s\S]*?--[ \t\n\r]*>@'         // Strip multi-line comments including CDATA 
    ); 
    $text = preg_replace($search, '', $document); 
    return $text;