cancel
Showing results for 
Search instead for 
Did you mean: 

Splitting the source text in to 70 chars for each tdline in target

former_member452321
Participant
0 Kudos

Hi
I am using following udf for splitting the text in to each 70 charcters to target each tdline which is working
But i need add the below logic in to it. can someone help

split the source text in to each 70 characters on each target tdline

But if the text contains  *
  copy string upto * in first tdline
  second tdline with the remaing text after *  continuous in loop for the
  remaining text 

else
copy with 70 charcters splitting for each tdline

Thanks for your help

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mahesh

I checked your UDF, looked very complex to me.

I wrote the below logic, please try it out.

Also i have added the new logic which you mentioned about *

As per my understanding if you have a string with 150 chars with * at 100th character

then it should be split like first 100 chars in first tdline and then remaining in 2nd.

If my understanding is wrong please correct me.

if(!var1[0].equals("") && !var1[0].contains("*"))

  {

  while (var1[0].length()>=70) {

  result.addValue(var1[0].substring(0,70));

  var1[0] = var1[0].substring(70);

  }

  result.addValue(var1[0]);

  }else{

  result.addValue(var1[0].substring(0,var1[0].indexOf("*")));

  result.addValue(var1[0].substring(var1[0].indexOf("*")+1));

  }

Regards

Osman

former_member452321
Participant
0 Kudos

Thanks Osman. If the string more than one * it is not working as expected. for example. input value = 1rwwewrwrre*2rwwwewrwwr*3werwrr.getting in first tdline 1rwwewrwrre and 2nd tdline =2rwwwewrwwr*3werwrr but expected  2rwwwewrwwr and third tdline value = 3werwrr

It there is no * it is working fine .

Thanks

Former Member
0 Kudos

I thought there will be only one * so i wrote such code.

Please use this

if(!var1[0].equals("") && !var1[0].contains("*"))

  {

  while (var1[0].length()>=70) {

  result.addValue(var1[0].substring(0,70));

  var1[0] = var1[0].substring(70);

  }

  result.addValue(var1[0]);

  }else{

String[] s = var1[0].split("\\*");

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

  result.addValue(s[i]);

  }

I just replaced the statements inside else condition.

Regards

Osman

former_member452321
Participant
0 Kudos

Thank you. It is working .

Answers (0)