cancel
Showing results for 
Search instead for 
Did you mean: 

splitting of element into 3 elements

Former Member
0 Kudos

Hi,

I tried to split name into fname,mname,lname at receiver side.I used UDf for that.But i'm getting the fname to all the three elements.Please help me to resolve this issue.

UDF:

String[] splitCodes = null;

for(int i = 0; i < inputVal.length; i++)

{

if( !(inputVal<i>.equals("")))

{

splitCodes = inputVal<i>.split(";");

for(int j = 0;j<splitCodes.length;j++)

{

result.addValue(splitCodes[j]);

}

}

}

if i provide a;b,c at source side i'm getting a for the 3 elements.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Radhika,

I tried to compile your code, doesn't work. Perhaps you can try the following:

1.) Create a UDF of type 'simple' and add two parameters, 'inputVal' and 'index'.

2.) Apply the following coding for your UDF:

int indexInt = Integer.parseInt(index);
        
        String[] splitCodes = null;
        splitCodes = inputVal.split(";");
        if((indexInt >= 0) && (indexInt < splitCodes.length)) {
            return splitCodes[indexInt];
        } else {
            return "";
        }

3.) Now you can use this UDF for your three output fields, always with name and a constant as input fields. For fname, you define the constant value '0', for mname you define '1' and for lname you define '2'.

Please reward points if this could help you.

Cheers,

Matthias

Answers (6)

Answers (6)

Former Member
0 Kudos

Thanks to all for ur support.

Former Member
0 Kudos

error

GabrielSagaya
Active Contributor
0 Kudos

String [ ] StrArray = inputVal.split(".");

for(int i=0;i<StrArray.length;i++)

result.addValue(StrArray<i>);

There is no difference in . and ,

Former Member
0 Kudos

Hi Math,

Thanks for ur reply.

I'm getting the output if i gave the seperator ",".But i'm not getting the output if i put "."(dot).Why this problem occurs?

Please give Reply.

Former Member
0 Kudos

Hi Radhika,

there shouldn't be a difference between ';' and '.', perhaps you can just check your input string?

Cheers,

Matthias

Former Member
0 Kudos

Try this code

String [ ] StrArray = inputVal.split(" "); // will sppit name into 3

result.addValue(StrArray[0]);

result.addValue(StrArray[1]);

result.addValue(StrArray[2]);

Edited by: Mugdha Kulkarni on Jun 16, 2008 7:55 AM

Former Member
0 Kudos
for(int j = 0;j<splitCodes.length;j++)
{
result.addValue(splitCodes[j]);
}

Looking at this it seems that you are adding all the three values in single context.

write 3 UDF to one for each and use it as

result.addValue(splitCodes[j0);

splitCodes[0] , 1 or 2 based on where you are mapping.

Gaurav Jain

Points if answer is helpful

Former Member
0 Kudos

Hi,

Try the following code,

String[] splitCodes = null;

for(int i = 0; i < idVal.length; i++)

{

splitCodes = idVal<i>.split(";");

int posVal = Integer.parseInt(position[0]);

if(posVal < splitCodes.length)

result.addValue(splitCodes[posVal]);

else

{result.addValue(ResultList.SUPPRESS);

}

}

depending upon 3 element put hte value either 0 , 1 or 2 in position[0].

Regards,

Rohit

Reward points if helpful