求助,C#正则匹配 * {margin: 0;padding: 0;}body{background-color:transparent;}body {font: 90%/normal Arial, Helvetica, sans-serif;}a:link {color: #00c;text-decoration: underline;}a:visited {color: #800080;}strong {color: #c03;font-weight: normal;
来源:学生作业帮助网 编辑:作业帮 时间:2024/08/02 22:38:19
![求助,C#正则匹配 * {margin: 0;padding: 0;}body{background-color:transparent;}body {font: 90%/normal Arial, Helvetica, sans-serif;}a:link {color: #00c;text-decoration: underline;}a:visited {color: #800080;}strong {color: #c03;font-weight: normal;](/uploads/image/z/11400980-68-0.jpg?t=%E6%B1%82%E5%8A%A9%2CC%23%E6%AD%A3%E5%88%99%E5%8C%B9%E9%85%8D+%2A+%7Bmargin%3A+0%3Bpadding%3A+0%3B%7Dbody%7Bbackground-color%3Atransparent%3B%7Dbody+%7Bfont%3A+90%25%2Fnormal+Arial%2C+Helvetica%2C+sans-serif%3B%7Da%3Alink+%7Bcolor%3A+%2300c%3Btext-decoration%3A+underline%3B%7Da%3Avisited+%7Bcolor%3A+%23800080%3B%7Dstrong+%7Bcolor%3A+%23c03%3Bfont-weight%3A+normal%3B)
求助,C#正则匹配 * {margin: 0;padding: 0;}body{background-color:transparent;}body {font: 90%/normal Arial, Helvetica, sans-serif;}a:link {color: #00c;text-decoration: underline;}a:visited {color: #800080;}strong {color: #c03;font-weight: normal;
求助,C#正则匹配
* {margin: 0;padding: 0;}
body{background-color:transparent;}
body {font: 90%/normal Arial, Helvetica, sans-serif;}
a:link {color: #00c;text-decoration: underline;}
a:visited {color: #800080;}
strong {color: #c03;font-weight: normal;}
主要是想要过滤掉这些代码,但是不知道怎么匹配,求助.
public static string RemoveHtml(string html)
这个测试过了,CSS里面的样式还是没有过滤掉.
有什么办法能直接过滤那些CSS吗?
求助,C#正则匹配 * {margin: 0;padding: 0;}body{background-color:transparent;}body {font: 90%/normal Arial, Helvetica, sans-serif;}a:link {color: #00c;text-decoration: underline;}a:visited {color: #800080;}strong {color: #c03;font-weight: normal;
public static string RemoveHtml(string html)
{
System.Text.RegularExpressions.Regex regex1 = new System.Text.RegularExpressions.Regex(@"",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex7 = new System.Text.RegularExpressions.Regex(@"
",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex8 = new System.Text.RegularExpressions.Regex(@"
",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex9 = new System.Text.RegularExpressions.Regex(@"]*>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
html = regex1.Replace(html,""); //过滤标记
html = regex2.Replace(html,""); //过滤href=javascript:() 属性
html = regex3.Replace(html," _disibledevent="); //过滤其它控件的on...事件
html = regex4.Replace(html,""); //过滤iframe
html = regex5.Replace(html,""); //过滤frameset
html = regex6.Replace(html,""); //过滤frameset
html = regex7.Replace(html,""); //过滤frameset
html = regex8.Replace(html,""); //过滤frameset
html = regex9.Replace(html,"");
html = html.Replace(" ","");
html = html.Replace("&","&");
html = html.Replace("","");
html = html.Replace("","");
html = html.Replace(">","<");
html = html.Replace("