cancel
Showing results for 
Search instead for 
Did you mean: 

Split value

Former Member
0 Kudos

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,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Thanks to all. All you given me enough solutions.

Answers (3)

Answers (3)

santhosh_kumarv
Active Contributor
0 Kudos

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...

Former Member
0 Kudos

Hi

I think the best approach would be to write a UDF for this functionality in Java. The shortest and easiest solution.

Regards,

Suddha

Former Member
0 Kudos

Hi Chinna,

you need a UDF where you have to use RegEx (Regular Expressions).

Regards, Mario

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

hi

create a UDF lookink for any number. once you find one cut from the beggining to the number position to get WORDS and position +1 to get numbers

Thanks

Rodrigo