cancel
Showing results for 
Search instead for 
Did you mean: 

Split string into different contexts of one field

Former Member
0 Kudos

Hi Gurus,

I have this requirement wherein I have to split a string into different contexts of this one output field. Splitting will be based on the "/" delimiter.

Example:

Source field - xxx/yyy/zzz

Target field (current without UDF) - xxx/yyy/zzz

I need a UDF wherein the values should split into 3 different contexts of the field.

Target field - xxx

Target field - yyy

Target field - zzz

Is this possible?

Thanks all for your replies!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos
String[] var = input.split("/");
for(int i=0;i<var.length;i++)
{
    result.addValue(var<i>); 
    if(i<var.length-1)
    {
        result.addValue(ResultList.CC);
    }
}
Former Member
0 Kudos

Hi Rajesh,

I'm having syntax errors everytime I use .split

Are there other options?

cannot find symbol

symbol : method split(java.lang.String)

location: class java.lang.String[]

String[] var = xxx.split("/");

Former Member
0 Kudos

use..

String[] var = input[0].split("/");

Answers (2)

Answers (2)

former_member463616
Contributor
0 Kudos

Hi,

Please use this UDF for your requirement.

You have to use delimiter as "/".

Like,

String[] temp;

String delimiter = "/";

temp = input.split(delimiter);

Please see the below thread, it will useful to you.

Regards,

P.Rajesh

zameerf
Contributor
0 Kudos

Can you please provide the source and target structure here?

Regards,

Zameer

Former Member
0 Kudos

<SourceStructure>

<SourceField>

</SourceStructure>

<TargetStructure>

<TargetField>

</TargetStructure>

The structures are simple. The mapping is complicated.

Former Member
0 Kudos

<SourceStructure>

<SourceField>

</SourceStructure>

-


>

<TargetStructure>

<TargetField>

<TargetField>

<TargetField>

<TargetField>

<TargetField>

</TargetStructure>

Multiple Target Fields depending on how many "/" was found in the source field.

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

You can try using three resultsets in your UDF e.g

result.addValue("xxx");

result1.addValue("yyy"); ...

You still have to declare them in your arguments though.

Hope this helps,

Mark