Extract all numbers before the last non zero digit with vb in uipath

I am trying to extract all numbers before the last non zero digits , i.e 1) if I have a number 4210014000000000 i am trying to extract only 4210014. 2) and if I have a number 621788000000000 i am trying to extract only 621788. 3)and if I have just 232322 then it should be 232322.

Hi,

Is your variable string type? If so, can you try the following expression?

System.Text.RegularExpressions.Regex.Match(yourString,"\d+?(?=0*$)").Value

If your variable type is int32, the following will work.

CInt(System.Text.RegularExpressions.Regex.Match(yourIntVar.toString(),"\d+?(?=0*$)").Value)

Regards,

Thanks Yoichi,
Thanks for you quick reply .
Yes it was a string, but I eventually found a way out of it.
I simply used in assign activity expectedstring = mystring.TrimEnd("0"c) and it works fine.
however ,I will go ahead to check out your method because i have really been trying to learn regex.

Regards

1 Like

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