正则表达式问题。。。。 删除 onmousewheel='return bbim(this)' onload='javascript:if(this.width>screen.width-600)this.width=screen.width-600;if(this.height>100)this.height=100;'剩下<IMG src='2.gif'/> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Re: minrange(Minrange) 你说的很对,怎么删除? 如果形式是:on*='*',其中单引号里面不能再包含单引号。求出所有匹配模式的正则表达式如下:on[a-z]+='[^']+'在对所有的匹配模式进行删除处理就行了 RE:V、97ce_twinkle(毛毛虫) 你的方法可行,但我发现有些标记里面不用' 和'的地方呢?比如onload=fun(); 那总得要其他分隔符可以分开其他属性的,比如说空格。on[a-z]+=[.]+\ RE:V、97ce_twinkle(毛毛虫) 对,有道理,谢谢你 看样子是应该可以了,但是还有问题。 我的原始字符串为:<IMG onmousewheel='return bbimg(this)' height=100 src='http://www.moongest.com/bbs/lt/UploadFile/200441110142526851.gif' onclick='fun();' onload='javascript:if(this.width>screen.width-600)this.width=screen.width-600;if(this.height>100)this.height=100;' border=0>正则表达式是:(<img[^>]*)(on[a-zA-Z ]+=(\s|')+[^']+(\s|')+)([^>]*>)结果输出的结果为:<IMG onmousewheel='return bbimg(this)' height=100 src='http://www.moongest.com/bbs/lt/UploadFile/200441110142526851.gif' onclick='fun();' border=0>即只过滤掉了最后一个onload有什么问题吗? 你的replace怎么写的?另外你这样写是整个字符串仅作为一次匹配给匹配进去了 (on[a-zA-Z ]+=(\s|')+[^']+(\s|')+)就行了 //我的意思是先从字符串中找出含有img标记的部分,然后把其中的事件过程过滤掉,并不事直接给出img部分去掉事件过程 string htmlString = @"<table><tr><td><IMG onmousewheel='return bbimg(this)' height=100 src='http://www.moongest.com/bbs/lt/UploadFile/200441110142526851.gif' onclick='fun();' onload='javascript:if(this.width>screen.width-600)this.width=screen.width-600;if(this.height>100)this.height=100;' border=0></td></tr></table>"; string regexString = ? string replaceString = ? Console.WriteLine(htmlString); htmlString = Regex.Replace(htmlString,regexString, replaceString,RegexOptions.IgnoreCase); Console.WriteLine(htmlString); 怎么计算文本框中文本的字节 C# 算法 为什么datagridview控件的列头的文字没法中间对齐? 求用MSchart制作winform曲线图的例子,急!!! 连接数据库问题? 谁能介绍下csharp的入门书籍 通俗点的 我刚学 简单的问题----(怎么学习 c# ) 希望使用经典简洁的语言! 有管ini的一个问题 有趣的 c# 请教mvc中的webapi 怎么设置helppage支持area? 散分,兄弟自己建立了一个增值业务的BBS,欢迎大家去捧捧场 比较简单的TABCONTROL问题,快来捡分...
你说的很对,怎么删除?
求出所有匹配模式的正则表达式如下:on[a-z]+='[^']+'在对所有的匹配模式进行删除处理就行了
你的方法可行,但我发现有些标记里面不用' 和'的地方呢?
比如onload=fun();
对,有道理,谢谢你
我的原始字符串为:<IMG onmousewheel='return bbimg(this)' height=100 src='http://www.moongest.com/bbs/lt/UploadFile/200441110142526851.gif' onclick='fun();' onload='javascript:if(this.width>screen.width-600)this.width=screen.width-600;if(this.height>100)this.height=100;' border=0>正则表达式是:
(<img[^>]*)(on[a-zA-Z ]+=(\s|')+[^']+(\s|')+)([^>]*>)结果输出的结果为:
<IMG onmousewheel='return bbimg(this)' height=100 src='http://www.moongest.com/bbs/lt/UploadFile/200441110142526851.gif' onclick='fun();' border=0>即只过滤掉了最后一个onload
有什么问题吗?
string htmlString = @"<table><tr><td><IMG onmousewheel='return bbimg(this)' height=100 src='http://www.moongest.com/bbs/lt/UploadFile/200441110142526851.gif' onclick='fun();' onload='javascript:if(this.width>screen.width-600)this.width=screen.width-600;if(this.height>100)this.height=100;' border=0></td></tr></table>";
string regexString = ? string replaceString = ? Console.WriteLine(htmlString);
htmlString = Regex.Replace(htmlString,regexString, replaceString,RegexOptions.IgnoreCase);
Console.WriteLine(htmlString);