on 08-05-2008 3:42 PM
Hi All,
I have field with value ABC12345'. This I want to split to 2 values. 'ABC into one field and '12345' into another field. The length of the input field value is not constant. some times it could be 'AB123'. So my requirement is i want to split charecters into one field and numbers into another field. Could you please help me ?
Thanks,
Hi,
you could use these two UDFs (parameter is in both cases called input 😞
getTextValue
if (input.length() > 0) {
for (int index = 0; index < input.length(); index++) {
if (Character.isDigit(input.charAt(index))) {
return input.substring(0, index);
}
}
}
return "";
getNumericValue
if (input.length() > 0) {
for (int index = 0; index < input.length(); index++) {
if (Character.isDigit(input.charAt(index))) {
return input.substring(index, input.length());
}
}
}
return "";
Regards
Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use this mapping.
source field -
> UDF1 -
> Character field.
source field -
> UDF1 -
> Numeric field.
UDF1
public String test(String a,Container container)
{
char array[] = a.toCharArray();
int temp,i;
for (i=0; i<array.length; i++)
{
temp = (int) array<i>;
if ( temp>= 48 && temp <=57)
return a.substring(0,i);
}
return a.substring(0,i);
}
UDF2
public String test(String a,Container container)
{
char array[] = a.toCharArray();
int temp,i;
for (i=0; i<array.length; i++)
{
temp = (int) array<i>;
if ( temp>= 48 && temp <=57)
return a.substring(i,a.length());
}
return a.substring(i,a.length());
}
Thanks
SaNv...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
I think the best approach would be to write a UDF for this functionality in Java. The shortest and easiest solution.
Regards,
Suddha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chinna,
you need a UDF where you have to use RegEx (Regular Expressions).
Regards, Mario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
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.