You can use a named capturing group to capture all parts of the number and then concatenate them. Although, it is more straight-forward to replace all chars you do not need as a post-processing step.
Here is an example code:
var pattern = @"^\$*(?:(?<v>\d{1,3})(?:,(?<v>\d{3}))*|(?<v>\d+))(?<v>\.\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<Capture>().Select(x => x.Value));
Console.WriteLine("{0} -> {1}", test, result.Length > 0 ? result : "No match");
}
See the C# demo. Output:
$100 -> 100
$12,203.00 -> 12203.00
12JAN2022 -> No match
The regex is
^\$*(?:(?<v>\d{1,3})(?:,(?<v>\d{3}))*|(?<v>\d+))(?<v>\.\d+)?$
See the regex demo. Details:
^
- start of string
\$*
- zero or more dollar symbols
(?:(?<v>\d{1,3})(?:,(?<v>\d{3}))*|(?<v>\d+))
- either one to three digits (captured into Group "v") and then zero or more occurrences of a comma and then three digits (captured into Group "v"), or one or more digits (captured into Group "v")
(?<v>\.\d+)?
- an optional occurrence of .
and one or more digits (all captured into Group "v")
$
- end of string.