Skip to Content
author's profile photo Former Member
Former Member

splitting of element into 3 elements

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 14, 2008 at 07:06 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2008 at 03:29 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2008 at 03:33 AM
    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2008 at 05:54 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2008 at 06:44 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2008 at 06:48 AM

    error

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 09:35 AM

    Thanks to all for ur support.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.