cancel
Showing results for 
Search instead for 
Did you mean: 

Separator UDF

Former Member
0 Kudos

Hi,

In the mapping Source field has the value XXX_YY_ZZ. I need XXX in target field1, YY in target field2 & ZZ in target field3.

Kindly suggest if any standard function s available or how to go about this.

eg

source abcd_abc_asdff

target field1 - abcd

target filed2 - abc

target field3 - asdff

Thanks in advance

Accepted Solutions (0)

Answers (2)

Answers (2)

rajasekhar_reddy14
Active Contributor
0 Kudos

If your source format standard then use substring function,if the length is going to vary then use sunil UDF.

sunilchandra007
Active Contributor
0 Kudos

Hi ,

You can create 3 UDF as shown below:

public String getStr1(String input, Container container)
{
String arr[] = input.split("_");
return arr[0];  // for other 2 string use arr[1] and arr[2]
}

or create ony one UDF with index also as a input.

Regards,

Sunil Chandra

Former Member
0 Kudos

Adding to sunil's comment..

you can include one more parameter for index.. to avoid separate UDF for each fields.

public String getStr1(String input, Container container)

Parameters: input, indexVal



String arr[] = input.split("_");
return arr[indexVal];  // for other 2 string use arr[1] and arr[2]

Mapping

Source + Constant (0 or 1 0r 2) -- > UDF -- > Target

Regards

Ramg