如下数据……
<font color=black >设计
<font color=red   ><b>广告
<font color=green > 艺术
当前字段数据(有这几种类型),我想将html替换为空!求一正则!!!
目前我是:replace(str,'<font color=','');但是不行,数据量比较大。

解决方案 »

  1.   


    /**
     * 转换字符串为纯文本
     * @param  $document string 文本
     * @return  $text   纯文本
     * **/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;
    }
      

  2.   

    交给php吧,mysql的正则函数只能匹配 不能替换,它不擅长这样的文本处理,数据量一大更是增加mysql负担
      

  3.   

    我需要将mysql不规则的数据进行处理。所以需要在mysql里面处理html标签。
      

  4.   

    导出来。替换。然后再到进去。
    或者用程序lun吧