cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve the right n characters from a string in Design Studio

mohd_abdullah
Contributor
0 Kudos
863

Greeting,

I would like to know how to retrieve the rightmost n characters from a string.

Example:

I have a string that contains value '1/1/21 ' . I need to get 21 from the string. I cant use substring with offset since I the length of the string is not fixed ...it changes like 21/12/19. In this case I need to get 19.

How do we accomplis this in Design studio ? Can I get this with split function ?

Thanks.

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Me just wishing there were more functions for handling STRINGS/TEXT in Lumira Designer such as e.g. REPLACE, TRIM, etc.

sinaei
Contributor
0 Kudos

Hello,

You can read the length of your value( in case of 1/1/21 it is 6 chracter)

var length = text.getText().length;

then change it to integer and do calculation like this:

var lastTwoChar= 6-2 

then with substring you can read the last two charcter:

Convert.subString(Text, lastTwoChar, length);

Hope it helps