using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; public class Test { public static void Main() { var pattern = @"^\$*(?:(?\d{1,3})(?:,(?\d{3}))*|(?\d+))(?\.\d+)?$"; var tests = new[] {"$100", "$12,203.00", "12JAN2022"}; foreach (var test in tests) { var result = string.Concat(Regex.Match(test, pattern)? .Groups["v"].Captures.Cast().Select(x => x.Value)); Console.WriteLine("{0} -> {1}", test, result.Length > 0 ? result : "No match"); } } }