Replace . to ,

How to replace 45.567.60 dot after first two nos with ,

1 Like

@Thi Check if this is what you needed:

it works but all dots converted to ,

@Thi So What Should the Output look like?

Hi @Thi

Try to explore regex for this issue.but if you have two character before changing the β€œ.” you can use substring and from that create again the string using the foreach loop and concatenate and the logic to add the β€œ,”

cheers :smiley:

Happy learning :smiley:

1 Like

Hi @Thi,

Are you sure you want to replace only the third character everytime?


This will work. Please mark as solution if this helped.

@Thi image

1 Like

This will work only if the dot is always at 3rd position. Better make it dynamic, to be in the safer side.

Hi @Thi,

I’m taking 1 example here for your better understanding, if Number = β€œ45.567.60”

  1. Num2 = "."+Number.Split("."C).Last
    β€”> Now Num2 will hold β€œ.60” as this is last value if we split with dot.

  2. Num1 = (Number.Replace(Num2,"")).Replace(".",",")
    β€”> Num1 will hold β€œ45,567”.
    because firstly we did Text1.Replace(Num2,β€œβ€) it means β€”> β€œ.60” with β€œβ€ β€”> β€œ45.567”
    Secondly Replace(β€œ.”,β€œ,”) β€”> so that it becomes β€œ45,567”

  3. NewNumber = Num1+Num2 β€”> Concatenation of strings β€œ45,567” & β€œ.60” β€”> β€œ45,567.60”

Note - This will always work, even on 23.44.566.78 β€”> 23,44,566.78
Because we’ve used .Last on splits Array so it’ll always remain last dot and replace other dots with comma.



@Thi Go for @samir 's Answer, I find it more Dynamically suitable :sweat_smile:

Thank you


cheers @Thi

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