Regex Match Numbers, ignore space, comma ,decimal dot

just lets do a quick stop:

as far I understood a valid value is

12,123.507 = Double 12123.507
12 123.507 = Double 12123.507
12 123,507 = Double 1212507
12 123 507 = Double 1212507
12,123,507 = Double 1212507

maybe an adopted strategy will better serve

  • extract with regex the variations
  • remove spaces
  • check with Double/Int32 .TryParse method if the value is valid or not.

However you will have a risk, as it is running on OCR
a value 12,345.589 recognized by OCR to 12 345 589 will be valid but not the same.

So, just check your options on this area as well while doing requirement analysis

2 Likes