using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; public class Test { public static void Main() { var texts = new List { "Na#me","M2a_ny","Vari{sq}o@us","test [sq]uirrel h23ere!" }; var pattern = @"((?:(?!{sq})[A-Za-z0-9\s])+)|{sq}"; foreach (var text in texts) { var result = Regex.Matches(text, pattern).Cast() .Aggregate("", (s, e) => s + e.Groups[1].Value, s => s); Console.WriteLine(result); } } }