using System; using System.Text.RegularExpressions; public class Test { public static void Main() { string patternMatch = @"(?:\([A-Z]+\))?FS[A-Z ]*-\d(?:[^\n,()-]*\w)?"; string patternReplace = @"(?<=^FS-[a-zA-Z0-9]*)[a-z]|[\p{Zs}\ta-z](?=[a-zA-Z0-9\p{Zs}\t]*$)"; string input = @"Fakturasadas : (S)FSK-69/23/GFK/12hjkhjkddddd (S)FSK-69/23/GFK/ 1 2 (S)FSK-69/23/GFK/12"; var strings = Regex .Matches(input, patternMatch) .Cast().Select(match => { return Regex.Replace( match.Value, patternReplace, "" ); } ); foreach (var s in strings) { Console.WriteLine(s); } } }