I want to replace (.) with (,) and viceversa


#1

i wanted to replace (.) with (,) and (,) with (.) for the below example
input: 3.377.542,07
output should be: 3,377,542.07
kindly help


#2

@Suman1 Is it format is same or it changes ?


#3

you could first replace the ‘.’ with ‘:’ for example then replace ‘,’ with ‘.’ and finally replace ‘:’ with ‘,’.


#4

usual pattern pickup some non-existent delimeter and replace to it first
value.Replace(",","#").Replace(".",",").Replace("#", “.”)


#5

@Suman1 Split the string by either . or ,. Let’s say you chose (.) Now you replace all the commas you get in the split array of strings with the dots. Then, concatenate them back, but add a “,” in between them.

For instance: 3.377.542,07. Splitting them using “.” (dot) as the delimiter will lead to this: {“3”,“377”,“542,07”}

Replacing the commas by dots in each of these strings will lead to this: {“3”,“377”,“542.07”}
Concatenate them back but add commas: “3”+","+“377”+","+“542.07” = “3,377,542.07”

Let me know if you have any queries.


#6

its working thanks