Extract the last four characters of any given string

Hey all,
I’m trying to figure out how to extract the last four characters of any given string.

For example:
“John Smith” --> returns: “mith”
“234-567-8977” --> returns: “8977”

I have tried using slice(), but in this case the length of the string is not fixed.

Please help. Thanks so much :slight_smile:

  • Mit

Dear @Mithaq_Abd_Mutalib, welcome to the community :handshake:

The below should be what you are looking for:


@Mithaq_Abd_Mutalib hey welcome! You will want to use the left() and right() functions for taking the last x characters off of a string. For example:

right("Welcome to Coda",4) = “Coda”
left("Welcome to Coda",4) = “Welc”


Dear @Jean_Pierre_Traets & @Johg_Ananda ,

Thank you very much for your prompt reply. :grinning: :+1:

1 Like

Hi there @Mithaq_Abd_Mutalib!
You could also use Text.slice(-4)
Here is some awesome explanation on this: