cancel
Showing results for 
Search instead for 
Did you mean: 

splitting a source filed

Former Member
0 Kudos

hi

i have a source structure having a field P_NAME and target structure having two filed ie F_NAME and L_NAME.

My requiremet is in i want to split the data that comes to P_NAME into the respective target filed.

for example: P_NAME = John Smith

now in

F_NAME = Jhon

L_NAME = Smith

with the code below i am able to populate F_NAME = John

but i am not able to do the same for L_SMITH.

int i = 0;

String temp = a[0].toString();

i = temp.indexOf(';');

result.addValue(temp.substring(0,i));

Regards

Kasturika

Accepted Solutions (1)

Accepted Solutions (1)

SudhirT
Active Contributor
0 Kudos

Hi,

Try like this,

int i = 0;
String temp = a[0].toString();
i = temp.indexOf(' ');
result.addValue(temp.substring(0,i));

and for second field

int i = 0;
String temp = a[0].toString();
int l = temp.length();
i = temp.indexOf(' ');
result.addValue(temp.substring(i,l-1));

Thanks!

Former Member
0 Kudos

hi Sudhir

thanks a lot.

int l = temp.length(); this is what i am looking for.

just i make a little modification in your coding to get the exact output.

result.addValue(temp.substring(i+1,l));

thanks

Kasturika

Answers (1)

Answers (1)

prateek
Active Contributor
0 Kudos

Have you created two such UDFs? For each target node you can create a UDF.

i = temp.indexOf(';');

As per you requirement you should take index of space.

Regards,

Prateek