需要一个正则, 能删除相应的src代码块<div style="text-align: center">
<img height="500" alt="" border="0" onload="if(this.width>=650)this.width=650;if(this.height>=500)this.height=500" src="xxxx" /></div>
<div> </div>例如:src为123
<div style="text-align: center">
<img height="500" alt="" border="0" onload="if(this.width>=650)this.width=650;if(this.height>=500)this.height=500" src="123" /></div>
<div> </div>
结果:空例如:src为456
<div style="text-align: center">
<img height="500" alt="" border="0" onload="if(this.width>=650)this.width=650;if(this.height>=500)this.height=500" src="456" /></div>
<div> </div>
结果:空除了src会变化外其他格式都很规范的为
<div style="text-align: center">
<img height="500" alt="" border="0" onload="if(this.width>=650)this.width=650;if(this.height>=500)this.height=500" src="xxxx" /></div>
<div> </div>
<img height="500" alt="" border="0" onload="if(this.width>=650)this.width=650;if(this.height>=500)this.height=500" src="xxxx" /></div>
<div> </div>例如:src为123
<div style="text-align: center">
<img height="500" alt="" border="0" onload="if(this.width>=650)this.width=650;if(this.height>=500)this.height=500" src="123" /></div>
<div> </div>
结果:空例如:src为456
<div style="text-align: center">
<img height="500" alt="" border="0" onload="if(this.width>=650)this.width=650;if(this.height>=500)this.height=500" src="456" /></div>
<div> </div>
结果:空除了src会变化外其他格式都很规范的为
<div style="text-align: center">
<img height="500" alt="" border="0" onload="if(this.width>=650)this.width=650;if(this.height>=500)this.height=500" src="xxxx" /></div>
<div> </div>
<div style="text-align: center">
<img height="500" alt="" border="0" onload="if(this.width>=650)this.width=650;if (this.height>=500)this.height=500" src="456" /> </div>
<div> </div>
结果:空
说实话,这个做法有点困难。首先你要把页面中的所有元素都取出来,然后在js中一个个取判断他的src是否为123.然后再删除。
说实话,这个做法有点困难。首先你要把页面中的所有元素都取出来,然后在js中一个个取判断他的src是否为123.然后再删除。
突然觉得 Java需要 C# 的 原生字符串支持. 就是 @那种.
可以用\d+,一般"\"需要转义,即src="\\d+"