// 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 Program { private static string parsePhp(string php) { return "#" + php + "#"; } private static readonly Regex re = new Regex(@"(<\?)(.*?)(\?>)", RegexOptions.Compiled | RegexOptions.Singleline); public static string Parse(string s) { string res = s; foreach(Match m in re.Matches(s)) { res = res.Replace(m.Groups[0].Value, parsePhp(m.Groups[2].Value)); } return res; } public static void Main(string[] args) { string s = @"
Dette er noget HTML
"; Console.WriteLine(Parse(s)); } } }