// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Text.RegularExpressions; namespace E { public class MainClass { public static Regex c = new Regex("/\\*.*?\\*/", RegexOptions.Singleline); public static Regex cpp = new Regex("//.*?\r\n"); public static string StripComments(string s) { return c.Replace(cpp.Replace(s, "\r\n"), ""); } public static void Main(string[] args) { string s = @"myobj* hat = new myobj(); //ny ting /* Husk at slette engang */ funccall( /* første parameter er en hat */ hat, nogetandet); delete hat;"; Console.WriteLine(StripComments(s)); } } }