using System; using System.Text.RegularExpressions; public class Test { public static void Main() { string text = "Hello world :low this \"but not this\" or 'this'"; text = Regex.Replace(text, @":\w+|""[^""]*""|'[^']*'|(.)", match => match.Groups[1].Success ? match.Groups[1].Value.ToUpper() : match.Value); Console.WriteLine(text); } }