cancel
Showing results for 
Search instead for 
Did you mean: 

UDF required

former_member1275317
Participant
0 Kudos

I have a requirement where i need to give 12 characters from right side...

for Ex.. if the incoming value is "abcedfghijkalmnopqrstuvwxyz"

then result should be "opqrstuvwxyz"...

Please give me some suggestions on this..

regards

Deep..

Accepted Solutions (1)

Accepted Solutions (1)

jyothi_anagani
Active Contributor
0 Kudos

Hi sandeep,

Take input as ur input string

This is code in UDF.


int len = string.length();
int len1 = len-12;
return string.substring(len1, len);

Map like this


inputString----------->UDF------->OutputString

Thanks.

Answers (2)

Answers (2)

Shabarish_Nair
Active Contributor
0 Kudos

>

> I have a requirement where i need to give 12 characters from right side...

>

> for Ex.. if the incoming value is "abcedfghijkalmnopqrstuvwxyz"

>

> then result should be "opqrstuvwxyz"...

>

> Please give me some suggestions on this..

>

>

>

> regards

> Deep..

the trick here would be to know if there will always be more than 12 characters in the input always.

If the input string will always contain more than 12 characters use the simple standard text function - substring

else use the UDF provided by jyoti. A little enhancement to it will be

try{
int len = string.length();
int len1 = len-12;
return string.substring(len1, len);
}
catch (Exception e)
{
return string;
}

this will ensure that even if the length is less than 12 the input string will be directly passed out and the UDF will not error out.

former_member181962
Active Contributor
0 Kudos

Do you already know the staring position? Or is it variable?

If not you can simple use the substring function.

Regards,

Ravi