anthonyjr
(Anthony)
November 11, 2022, 5:53am
1
I want to check a string if it ends with a single zero (e.g. 123.0) and if does I want to add another zero “123.00” but if doesn’t (e.g. 10500.25) it will not do anything to that string and will just remain as 10500.25.
I’m thinking this will be a combination of If and Regex.
How can I implement this logic?
Any kind of help would be appreciated.
Regards,
Anthony Jr.
Yoichi
(Yoichi)
November 11, 2022, 5:57am
2
Hi,
Can you try the following expression?
Double.Parse(yourString).ToString("#.00")
Regards,
2 Likes
Gokul001
(Gokul Balaji)
November 11, 2022, 5:58am
3
HI @anthonyjr
You can trey with Regex expression
System.Text.RegularExpressions.Regex.Ismatch(YourString,"0$")
In the Then
System.Text.RegularExpressions.Regex.Replace(YourString,"0$","00").Tostring
Regards
Gokul
1 Like
anthonyjr
(Anthony)
November 11, 2022, 6:04am
4
It’s working perfectly. Thank you so much for your expertise sir @Yoichi
Best Regards,
Anthony Jr.
1 Like
HI @anthonyjr
Checkout this
if(Split(str,".")(1).ToString.Length=2,str,Double.Parse(str).ToString("#.00"))
Regards
Sudharsan
system
(system)
Closed
November 14, 2022, 6:06am
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.