How to replace 45.567.60 dot after first two nos with ,
it works but all dots converted to ,
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
Happy learning
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β
-
Num2 = "."+Number.Split("."C).Last
β> Now Num2 will hold β.60β as this is last value if we split with dot. -
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β -
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.
45,567.60
Thank you
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.