日期:2014-05-18  浏览次数:20444 次

求一正则表达式,顺祝中秋快乐
将字符串:
<img   src= "IMGP7406.JPG "   width= "300 "   height= "250 "   style= "width:100px;height:100px ">

替换成:
<img   src= "IMGP7406.JPG "   style= "width:100px;height:100px ">

有一正则表达式,并祝大家中秋快乐!

------解决方案--------------------
sf
------解决方案--------------------
顶一下,大家中秋快乐.JF
------解决方案--------------------
不怎么会正则,帮顶,接分
------解决方案--------------------
路过,不懂,帮顶一下
------解决方案--------------------
不怎么会正则,帮顶,接分

------解决方案--------------------
帮顶~ 预祝中秋快乐啊
------解决方案--------------------
var str = ' <img src= "IMGP7406.JPG " width= "300 " height= "250 " style= "width:100px;height:100px "> ';

var reg = /(height|width)=[ " ']\d+[ " ']/gi;
alert(str.replace(reg, " "));
------解决方案--------------------
Regex.Replace(str, @ "width=[ ' " "]?\d+[ ' " "]?\s*height=[ ' " "]?\d+[ ' " "]? ", " ");
------解决方案--------------------
Regex.Replace(a, "\s+width=[ " ']?\d+[ " ']?\s+height=[ " ']?\d+[ " ']? ", " ");
============
多了个^
------解决方案--------------------
Regex.Replace(str, @ "(height|width)=[ " ']\d+[ " '] ", " ");