求?mysql一正则??

码无边 2012-04-01 03:56:51
如下数据……
<font color=black >设计
<font color=red ><b>广告
<font color=green > 艺术
当前字段数据(有这几种类型),我想将html替换为空!求一正则!!!
目前我是:replace(str,'<font color=','');但是不行,数据量比较大。
...全文
105 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
coder 2012-04-01
  • 打赏
  • 举报
回复
导出来。替换。然后再到进去。
或者用程序lun吧
码无边 2012-04-01
  • 打赏
  • 举报
回复
我需要将mysql不规则的数据进行处理。所以需要在mysql里面处理html标签。
代码如诗 2012-04-01
  • 打赏
  • 举报
回复
交给php吧,mysql的正则函数只能匹配 不能替换,它不擅长这样的文本处理,数据量一大更是增加mysql负担
tottyandbaty 2012-04-01
  • 打赏
  • 举报
回复

/**
* 转换字符串为纯文本
* @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;
}

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧