<textarea id="wc" style="width:300px; height:300px;">想用正则表达式替换内容中含有如下格式的字符
width="90" 或者 width=100 或者 width='210'
height="100" 或者 height=200 或者 width='300'</textarea>
<script type="text/javascript">
window.onload = function () {
var pa = /[ ]?(?:height|width)=(?:'[^']+'|"[^"]+"|\d+)/gi
, wc = document.getElementById("wc");
wc.value = wc.value.replace(pa, "");
};
</script>
width="90" 或者 width=100 或者 width='210'
height="100" 或者 height=200 或者 width='300'</textarea>
<script type="text/javascript">
window.onload = function () {
var pa = /[ ]?(?:height|width)=(?:'[^']+'|"[^"]+"|\d+)/gi
, wc = document.getElementById("wc");
wc.value = wc.value.replace(pa, "");
};
</script>
解决方案 »
- jquery及ajax 都验证通过 为什么这个方法最后返回false,急死了
- 一道课题求解
- IE8开发人员工具出问题了,求助~~
- 我用jquery写了一个鼠标移入时暂停的程序,但是只有在IE里用F12-debug后才能用
- 求一个关于汉字得javascript,急等!
- 请教一个Microsoft.XMLHTTP 返回的值的执行问题,在线等
- 修改json格式
- 如何让文本框的默认值以2004-04-15的格式显示当前的日期?
- 美女用身体写作,我用高分换答案!!!
- jqgrid中form表单属性设置以及如何提交表单后自动关闭form表单
- js 数字和字符串问题 不知为什么
- 如何在表格中隐藏一个单元格,但不改变表格的布局?
怎么没人回答。。你的需求也没说明白,替换成空的话就是上面的CODE即可。。如果你还想在严紧的话说明下具体需求。
alert(m.replace(/ (.*?=[\'\"]\d+[\'\"])/g," "))
var str='asdads width="90" 或者 width=100 或者 width=\'210\' height="100" 或者 height=200 或者 width=\'300\' sdfsdf'
re=/((height)|(width))\s*=\s*(["']?)\d+\4/ig
var result=str.replace(re,"")
alert(result)
</script>