using System; using System.Text.RegularExpressions; public class Test { public static void Main() { string input = @"\test"; bool result = !Regex.IsMatch(input, @"[""'\\]+"); // result is true if no match if (!result) { Console.WriteLine("Comments cannot contain quotes (double or single) or slashes."); } } }