using System; using System.Text.RegularExpressions; namespace HowTo { public class dataHandler { public dataHandler() { } /// /// csharpConvertString is used for converting my c# syntax inside my code /// /// This is the input string that we want to conver /// returns a fixed string with replaced highlighting public static string csharpConvertString(string strConvert) { /************* Input exampel***************/ // [c-sharp] // using System; // string strTest = new string; // [/c-sharp] // /******************************************/ string strConvertedString = strConvert; string[] regExpPattern = new string[2]; regExpPattern[0] = @"(\[csharp\])(.*)(using)(.*)(\[\/csharp\])"; regExpPattern[1] = @"(\[csharp\])(.*)(string)(.*)(\[\/csharp\])"; regExpPattern[1] = @"(\[csharp\])(.*?)(\r\n)(.*?)(\[\/csharp\])"; string[] regExpReplace = new string[2]; regExpReplace[0] = @"$1font color=blue>$3$4"; regExpReplace[1] = @"$1$3$4"; regExpReplace[1] = @"$2
$3"; /* */ for ( int i = 0 ; i < regExpPattern.Length; i ++) { strConvertedString = Regex.Replace(strConvertedString, regExpPattern[i], regExpReplace[i]); } return strConvertedString; } } }