on 01-22-2013 7:11 AM
Hello All,
i have written an UDF which will trim the leading zeros. i have not used standard functions as some time data will contain special char.
now problem is UDF is trim leading zeros till 9 char only and the field length is 18 char.
kneed ur help on this.
for (int i = 0 ;i < a.length() ; i ++ )
{
if (a.startsWith(" ") || a.startsWith("0") )
{
a = a.substring(1, a.length() );
}
else
break;
}
return a;
Regards,
chinna
Hi,
Please try this:
int j = a.length();
for (int i = 0 ;i < j; i ++ )
{
if (a.startsWith(" ") || a.startsWith("0") )
{
a = a.substring(1, a.length() );
}
else
break;
}
return a;
Regards,
Beena.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
For removing leading Zeroes try the below simple code .
return ISN.replaceFirst("^0+(?!$)", "") ;
ISN -->Input String
Add this import statement -->java.util.regex.*
Examples:
01234 converts to 1234
0 remains as 0
1234 remains as 1234
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
9 | |
9 | |
8 | |
7 | |
7 | |
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.