on 03-01-2007 3:40 PM
Hi group,
I have one string with length 15 ,sometimes I am getting this fields with in between sapces and hyphen(-) ,how to remove these spaces and hyphen using JAVA in UDF.
Can any suggest
Also might want to use the standard function 'trim' to remove leading and trailing blank spaces....
Thanks,
Renjith
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So is what you want some thing like pass all the numeric values in the 15 character long string..is it ?
if yes please use this code in UDF...
int len = input.length();
String output = "";
for(int i = 0; i < len; i++){
if(Character.isDigit(input.charAt(i))){
output+= input.charAt(i);
}
}
return output;
Thanks,
Hi,
Why do you need a UDF for this ? Can't you use 'replaceString' standard function ?
Thanks,
Renjith
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
just create a UDF with a String argument a:
int i = a.length();
String b="";
Char c;
for (int j=0; j<i; j++)
{
c=a.charAt(j);
if (c!=' ' && c!='-')
b=b+c;
}
return b;
Thanks,
Rajeev Gupta
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 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.