Remove last Digits

Hi,

I would like to please about help or advice. I got array of string:

And on the end of all phrases i got number… how to recognize and remove this digits… solution must be dynamic because the length of string are changing.

Regards
@fudi5

I’m not sure exactly what you are wanting, but you can look maybe online for a Regex pattern that will extract only the numbers that end a string.

It might be a pattern like this: “[0-9]{1,2}$”, which says a number 1-2 digits that ends the string ($)

To use the pattern, you can do something like the below:

System.Text.RegularExpressions.Regex.Match( text, "[0-9]{1,2}$").Value

Hope that helps.

Regards.

1 Like

You need to remove the last digit alone ? or need to eliminate after reaching some length?

(yourString.TrimEnd().Substring(0, yourString.Length - 1) will remove the last character

Hi @karthick

So cut last character is not a solution… look on pictures… one time you got “1.1” next time only “2.” other line got 2.1 it must be removed.

@ClaytonM thx mate ill try this solution.

Regards
@fudi5

Hi @fudi5,

strinput=System.Text.RegularExpressions.Regex.Replace(strinput,"\d*[.]$|\d*[.] \d*$","")

Regards,
Arivu

1 Like

Then follow @ClaytonM procedure and replace it using Regex.

Since you need the decimal, you might also try @arivu96’s

which basically says to extract ending number with decimal on end OR ending number with decimal and another number.

1 Like

I have question related to this… for ex i am having a no lik thus 1,234.00 i want to remove decimal point and 2 zeroes from this. How to remove those can any1 help m

how to use in uipath activity? which activity I should put. and inside that I can insert regex