Hi all, I need a regex pattern that will work with an excel cell which will have different invoice amount values. Excel cell value + Pattern will go into a folder of differnent PDF’s then try match the value in the pdf.

Sample:

Excel value will always be changing
excel cell value - 1236

Expected Output:
Match all these possible outcomes of Invoice total amount format structures:
-1923.00
-1,923.00
-$1923

The Pattern:
I found this pattern which is able to highlight the amount regardless of format - \d+(.\d+)?

Each pdf displays the invoice total amount in different, just attempting to make sure the cell value and total amount value in the Invoice match.

Replace the characters -, $ and , with “” like var1.replace(“$”,“”).replace(“-”,“”).replace(“,”,“”). This doesn’t throw exception even if var1 doesn’t contains $ or , or -. After executing this command, just number part will be remaining like 1236.00

Convert this var1 to double using Convert.Todouble(var1)

Also convert your excel cell value to double, if it’s not in double format

Now you can compare excel cell value and pdf amount

Thank you so much, those the only currency variations. So if 1236 is my cell value, I will be able to make the pattern reference that value then use it to find the Invoice amount no matter the format of the number?

I’m not able to figure out the complete process from your xaml file. Also some dependencies are not resolved in my studio.

I suggest you to use the regex pattern “-?($|ZAR|R)?\d,?\d+(.\d+)?” to match the amount from PDF and excel.
Once you get the amount value(both for pdf amount and excel value), you can use replace method to replace all unnecessary characters as I said in my previous replies.
Convert both PDF amount and excel values to double.
Then use for loop and if condition to match the values as per your requirement.