This article mainly introduces the method of C# based on regular rules to remove comments, and analyzes C#'s regular matching operation skills for comment symbols in the form of simple examples. Friends who need it can Refer to the following
The example of this article describes the method of removing comments in C# based on regular rules. Share it with everyone for your reference, the details are as follows:
string HoverTreeClearMark(string input) { input = Regex.Replace(input, @"/\*[\s\S]*?\*/", "", RegexOptions.IgnoreCase); input = Regex.Replace(input, @"^\s*//[\s\S]*?$", "", RegexOptions.Multiline); input = Regex.Replace(input, @"^\s*$\n", "", RegexOptions.Multiline); input = Regex.Replace(input, @"^\s*//[\s\S]*", "", RegexOptions.Multiline); return input; }
The above is the detailed content of C# example of method to remove comments based on regular expressions. For more information, please follow other related articles on the PHP Chinese website!