Substring to Get Certain Number of Letters From The Right

  • 27 March 2019
  • 3 replies
  • 19 views

Badge +3

The fn-Substring(a,b,c) is useful when we start count from the string left side.
What if i want to get the x number of characters from the right side where the strings can have different length?
For example if X=4
The input for:
Abcd-1234
Ab(xyz)1234
Abcdefxyz1234
All need to give the Output as 1234


3 replies

Badge +9

You can use a regular expression. Result will be assigned to a single line text variable:

 

1214iF215E4F1A4C3551E.png

if you want it to be exactly four digits, use d{4,4} instead of d+.

Badge +3

Thank you Mlauer for your reply,
But sorry couldnt get it to work, or maybe I missed something.
in my example, when i mentioned 1234, i mean any four alphanumiric characters, it doesnt mean the last for letters are always numbers,
also the input string is not always the same size, it can be any number of alphanumeric string

Badge +9

To get 4 last characters of a string use:

.*(.{4,4})$

Reply