cancel
Showing results for 
Search instead for 
Did you mean: 

UDF to Off-set from right

Former Member
0 Kudos

Hi All,

I need a UDF to pass the last seven characters from my string.

If i have a string whose value is 'abcdefghkdk' then my UDF should return 'efghkdk'.

I tried with the below UDF and it throws an error saying array required, but java.lang.String found out = out +a[k];

public String ZOffset(String a,Container container){

String out ="";

int i = a.length();

int j = i - 7;

for(int k=j;k<i;k++)

{

out = out +a[k];

}

return out;

}

Please let me know what is the error in this or if there is any other UDF available to achieve the same.

Thanks in advance,

Sai

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sai,

Please use the below code, it will work perfectly.

int len;

String outVal;

len = a.length();

outVal = a.substring(len - 7);

return outVal;

Regards

Ramg

Answers (0)