on 05-20-2009 11:16 AM
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..
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>
> 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you already know the staring position? Or is it variable?
If not you can simple use the substring function.
Regards,
Ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.