cancel
Showing results for 
Search instead for 
Did you mean: 

Data split and remove the rest

0 Kudos

Hi Experts,

I need an udf to split the data in runtime.

Please find the example below:

Input --

1. GENERAL (General II & IV SAT OFF)

2. G3 (8.30am-5pm)

And I need the output as : 

1. GENERAL

2. G3

Please help me with this. The data in the brackets is not required, I only require the data which is not in brackets.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Praveen,

use below code to get substing before the opening bracket.  In UDF  select Execution type as All Values of a context.

public void split(String[] input, ResultList result, Container container)throws StreamTransformationException{

int beginIndex = 0;

int endIndex = 0;

for(int i=0; i<input.length; i++){

endIndex = input[i].indexOf("(");

result.addValue(input[i].substring(beginIndex, endIndex));

}

}

Regards,

Santhi

0 Kudos

Than you very much. The above code solve my issue.

Answers (1)

Answers (1)

former_member184948
Active Participant
0 Kudos

Hi Praveen ,

If I understand your question properly, then can we not use "SubString" function under Text function in ESR itself, than using UDF.

0 Kudos

Yes, we can use substring only for fixed length of the string data.

But in my case the data length is not fixed hence I have opted for UDF.