on 05-08-2007 9:59 AM
HI
Experts
i need to help of writing udf
my source value is :000234 result willbe 234
023456 23456
004537 4537
like this how can i achive this ; my source as fixedlength is 6 digts as string
any expert can help me
thanks&ragards
kumar
Hi,
/******UDF********/
String a= "000234";
int pos= 0;
for(int i=0;i<a.length();i++){
if(Character.isDigit(a.charAt(i))&& !a.substring(i,i+1).equalsIgnoreCase("0")){
pos = i;
break;
}
}
return( a.substring(pos));
Please check this code.
Cheers!
Samarjit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi-
Try this program
public static String removeLeadingZeros(String str) {
if (str == null) {
return null;
}
char[] chars = str.toCharArray();
int index = 0;
for (; index < str.length; index++) {
if (chars[index] != '0') {
break;
}
}
return (index == 0) ? str : str.substring(index);
}
Note: Here 'str' in the string you are passing
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
have u tried with 'formatNum' function in the arithmetic functions....as a parameter to this function just put '#'...
also check for the The Function Round ( under Arithmetic ) might help you
if trying with UDF u can go for
String output = inputVal.replaceFirst("^0+","");
return output;
or also
int Seq = Integer.parseInt(inputVal)
This will suppress all the leading zeroes
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.