How to use regular expressions to filter HTML tags in C #
This article introduces the knowledge of "how to use regular expressions to filter HTML tags in C#". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The details are as follows:
Public static string FilterHtmlTag (string s) {/ / Mark regular expression return Regex.Replace (s, @ "] * >", delegate (Match match) {string v = match.ToString (); / / Picture
The regular expression Regex rx = new Regex (@ "^ $", RegexOptions.Compiled | RegexOptions.IgnoreCase); / / if (rx.IsMatch (v)) {return v; / / keep the picture
} else {return "; / / filter out}});}
Everything on my side is filtered, so I directly use regular, no longer do anonymous delegate reservation p and br
Content = Regex.Replace (content, @ "/\\ S*\ / g", ", RegexOptions.IgnoreCase); content = Regex.Replace (content, @"] * > ",", RegexOptions.IgnoreCase); content = content + "." ; "how to use regular expressions to filter HTML tags in C#" is introduced here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!