php正则过滤字体样式

苹果 发表于2019-03-08 11:58:52 preg_replace 2148

过来文本中自带的字体样式,如ont-family等

preg_replace('#font-family:[^;]+?;#i','',$str);


preg_replace('#font-size:[^;]+?;#i','',$str);


去除所有style

preg_replace('/style=\".*?\"/','',$str);


去除img,width,height

$txt1 = preg_replace( '/(<img.*?)(style=.+?[\'|"])|((width)=[\'"]+[0-9]+[\'"]+)|((height)=[\'"]+[0-9]+[\'"]+)/i', '$1' , $txt1);


获取文章中所有的图片

preg_match_all("/<img.*?src=[\'|\"](.*?(?:[\.gif|\.jpg|\.png|\.jpeg]))[\'|\"].*?[\/]?>/", $info['content'], $match);



3条评论
  • 2222 2019-04-23 17:57:49 1#

    222

  • 222 2019-04-23 17:57:45 2#

    222

  • 111 2019-04-23 17:57:40 3#

    1111

Copyrights © 2016-2017 何冰华个人网站 www.hebinghua.com, All rights reserved. ICP证:豫ICP备17048782号-1
关键词:何冰华,心灵语丝,PHP,Linux,个人随笔,学习笔记