日期:2014-05-18 浏览次数:20492 次
<img onclick="return 1;" /> <a onmouseover="fu_te();" >测试</a>
string str = @"<a onload=""alert();"" >a onload=""alert();""</a> <img onload=""dsdfsf();dfsfs();"" /> onload=""alert();"" <div onload=""sf()"" onmousermove=""sdfsfwe();"">sf onload=""alert();"" sf </div>"; string result = Regex.Replace(str, @"(?is)(?<=<\b[^\s]+\b[^>]*?)\bonload=""[^""]+""(?=[^>]*?>)", ""); Console.WriteLine(result); /* <a >a onload="alert();"</a> <img /> onload="alert();" <div onmousermove="sdfsfwe();">sf onload="alert();" sf </div> */