Get last 3 characters from string excepting the last 1 character

Hi devs, pls how do I extract the last 3 xters excepting the last 1 character from this string.Example I have “Porridge” and I want to get “idg”
“School” to get “hoo”

@RPA-botDev

Try below expression.

     strInput.Substring(strInput.Length-4,3)

Here strInput variable holds your input string.

2 Likes

Hi @RPA-botDev,

A dynamic alternative : Left(Right("Porridge",4),3)

This takes four last characters first, then it takes the first 3 characters.
image

Left(Right("School",4),3)
image

2 Likes

Hi Lakshman, is there a dynamic variable holding 4, or for all strings I should add length-4?

@RPA-botDev

You can add -4 for all strings as per your required output.

1 Like

grafik
handling too short strings as well

2 Likes

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