cancel
Showing results for 
Search instead for 
Did you mean: 

Require help in UDF

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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.

Answers (1)

Answers (1)

Former Member
0 Kudos

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