on 07-27-2011 5:01 AM
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
answered
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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--
111(output
1(constant)----
OR
you can use two times standard arithmatic Neg function
Source--
>Output
000111----
111
Or
You can use FormatNum Function
Put Number format as Blank
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
chk this udf:
input will be "a"
Execution type: single value
String regex = "^0+";
String replacement = "";
a = a.replaceAll(regex, replacement);
return a;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try with below code, var1 argument.
String S= var1.replaceFirst("^0*","");
return S;
Regards,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Use the arithmetic function called formatNum. Here is the mapping
Source -> formatNum: 0 -> Target
Hoep this helps,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
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.