.Replace question

Hello,

Using Document Understanding process, I’ve extracted data from a dataset of invoices.
I have a problem with one specific input data from an invoice.
It looks like this: eg. 3,329.86 and it represents a Total.
In order to insert this Total into system I have to rewrite it as: 3.329,86 to be processed as a correct value.

My question is: How can I use .Replace(valueToBeReplaced, replaceValue) in order to make this change of the input data in the same time even for ‘,’ and for ‘.’ ?
As a resume, I have to change the input ‘,’ with ‘.’ and the input ‘.’ with ‘,’.

Thank you!

1. replace ,/. with something else
txt = txt.Replace(",", "COMMA")
txt = txt.Replace(".", "FULLSTOP")
2. now we can perform the actual replace
txt = txt.Replace("COMMA", ".")
txt = txt.Replace("FULLSTOP", ",")
1 Like

Hi,

Unforunatelly, Srting.Replace cannot replace 2 string pattern at same time.
So can you try the follwiong expression, for example?

"3.329,86".Replace(",",chr(9)).Replace(".",",").Replace(chr(9),".")

Regards,

1 Like

Thank you so much for your idea!

Thank you for your reply! :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.