using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; public class Test { public static void Main() { var str = "A tab\there \"inside\ta\tdouble-quoted\tsubstring\" some\there"; var pattern = "\"[^\"]+\""; // A pattern to match a double quoted substring with no escape sequences var result = Regex.Replace(str, pattern, m => m.Value.Replace("\t", "-")); // Replace the tabs inside double quotes with - Console.WriteLine(result); } }