这篇文章主要介绍了c#基于正则去掉注释的方法,结合简单实例形式分析了c#针对注释符号的正则匹配相关操作技巧,需要的朋友可以参考下
本文实例讲述了c#基于正则去掉注释的方法。分享给大家供大家参考,具体如下:
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;
}
以上就是c#基于正则表达式去掉注释的方法示例的详细内容。