1: //<summary>
2: /// Remove HTML tags
3: // </summary>
4: /// <param name= "nohtml" > including HTML source code </param>
5: /// <returns> removed text after </returns>
6: public staticstring removehtml (string htmlstring)
7: {
8: if (string. IsNullOrEmpty (htmlstring))
9: {
Ten: returnstring. Empty;
One : }
: //Delete script
@ "<script[^>]*?>.*?</script>" ", Regexoptions.ignorecase);
:
: //delete HTML
: @ < (. [ ^>]*) >"", regexoptions.ignorecase);
: @ "([\ r \ n]) [\s]+""", regexoptions.ignorecase);
: @ "--" "", regexoptions.ignorecase);
: @ "<!--. *" "" ", regexoptions.ignorecase);
: @ & (quot| #34); "\" ", Regexoptions.ignorecase);
: @ "& (amp| #38);" "&", regexoptions.ignorecase);
: @ "& (lt| #60);" "<", regexoptions.ignorecase);
At : @ "& (gt| #62);" ">", Regexoptions.ignorecase);
@ "& (nbsp| #160);" "", Regexoptions.ignorecase);
@ "& (iexcl| #161);" "\xa1", regexoptions.ignorecase);
: @ "& (cent| #162);" "\xa2", regexoptions.ignorecase);
@ "& (pound| #163);" "\xa3", regexoptions.ignorecase);
: @ "& (copy| #169);" "\xa9", regexoptions.ignorecase);
£ º @ "(\d+);" "", Regexoptions.ignorecase);
: htmlstring.replace ("<" ");
To : htmlstring.replace (">" ");
: htmlstring.replace ("\ r \ n"");
:
: return htmlstring;
: }
£ º
Panax Notoginseng :
Block : #region Regular expression replaces script code that contains scripts for scripting attacks
// / <summary>
Max : /// Regular expression replace script code with script attack
In : /// author:Andrew.He
// / </summary>
// / <param name= "scriptstring" > String containing script attack </param>
A : /// <returns> Replace script attack string </returns>
: public staticstring removescript (string scriptstring)
: {
A : if (string. IsNullOrEmpty (scriptstring))
: {
£ º return scriptstring;
: }
Wuyi:
: //Perform a replacement operation
: @ "<[]*script""[Script", regexoptions.ignorecase);
Si : @ "/[]*script[]*>" "/script]", regexoptions.ignorecase);
:
£ º return scriptstring;
£ º }
: #endregion