on 05-03-2010 4:59 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.