cancel
Showing results for 
Search instead for 
Did you mean: 

Need UDF for splitting string

former_member229310
Active Participant
0 Kudos

Hi All,

I have an input field with the payload value in the source structure as xxx_abc_yyyy_2010.txt .

I need string abc for one of the target field1 and 2010 for another target field 2.

Please suggest.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

your requirement is a simple text formatting and can be achieved by substring function.

So better you use the standard function itself as these are precompiled and enhances your scenario performance.

cheers,

Abhishek.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi

UDF for Splitting

pass 2 arguments strInput,in

strInput -- is your argument (source value- aaa_bbbb_ccc)

in -- array index parameter say 0 or 1 or 2, etc.....

================


String[] Values = strInput.split("_");
return Values[in];  

=================

o/p:

Values[0] --- aaa

Values[1] --- bbbb

Source+Constant(0 or 1 0r ... ) -- > UDF -- > target

Regards

Ramg

Former Member
0 Kudos

You can use the 'substring' function which is standard.

if you insist on a UDF, you will need to create two for each target field if you're using 3.0 / 7.0:

UDF 1 (input FFileName)

target1 = FFileName.substring(4,7);

return target1;

UDF 2 (input FFileName)

target2 = FFileName.substring(13,17);

return target2;

Regards,

Glenn

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi Learner,

No need of UDF,use subString function it will work for you.

Regards,

raj