Home > Backend Development > C#.Net Tutorial > C# example of method to remove comments based on regular expressions

C# example of method to remove comments based on regular expressions

黄舟
Release: 2017-05-28 10:06:04
Original
1839 people have browsed it

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;
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template