cancel
Showing results for 
Search instead for 
Did you mean: 

UDF

Former Member
0 Kudos

Hi,

Can you help me for the UDF for removing the leading zeroes of the input value?

The requirement is that if the input is 00012345,then the output should be without zeroes,that is,thae output should be 12345.

Please help me

Thanks in advance

Edited by: Shweta Kullkarni on Jul 27, 2011 6:01 AM

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

answered

Former Member
0 Kudos

Hi Shweta,

You can multiply with 1 which removes leading zeros. But if you have a character it will not work. So you need to write a UDF to check whether the input is numeric or having alphabets. If numeric multiply with 1 else dont do anything pass what ever you have input.

If you think its always numeric multiply with 1 should take care.

Regards,

---Satish

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>The requirement is that if the input is 00012345,then the output should be without zeroes,that is,thae output should be 12345.

Why do u want udf? THis is pretty simple requirement. Looks like you get the input value always number.

So use formatnum standard function.

former_member854360
Active Contributor
0 Kudos

Hi shewata,

if you are getting only numeric value then You dont need to write any UDF for this requirement.

Simple

Multiply the input with constant 1 you will get desired output

000111--


Multiply(Standarad arithmatic function)--


111(output

1(constant)----

OR

you can use two times standard arithmatic Neg function

Source--


>NEG
>NEG
--


>Output

000111----


111

Or

You can use FormatNum Function

Put Number format as Blank

Former Member
0 Kudos

chk this udf:

input will be "a"

Execution type: single value

String regex = "^0+";

String replacement = "";

a = a.replaceAll(regex, replacement);

return a;

rajasekhar_reddy14
Active Contributor
0 Kudos

Try with below code, var1 argument.

String S= var1.replaceFirst("^0*","");
return S;

Regards,

Raj

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Use the arithmetic function called formatNum. Here is the mapping


Source -> formatNum: 0 -> Target

Hoep this helps,

Mark