Andrej Andrej - 3 months ago 26
C# Question

regular expression needed to remove C/C# comments

I need a C# regex to delete everything between

/*
and
*/
including the
/**/
.
So, basically remove all code comments in the given text.

Answer

Should be something like this:

var regex = new Regex("/\*((?!\*/).)*\*/", RegexOptions.Singleline);

regex.Replace(input, "");