Split string depending on 4000 char limit

I want to update a particular string in a text box, however char limit is 4000 chars at a time.

  1. If the string is > than 4000 and < 8000 then I need to split it in two parts
  2. If the string is > than 4000 and < 12000 then I need to split it in three parts
  3. If the string is > than 4000 and < 16000 then I need to split it in fours parts

Can anyone have a solution on this please?

Hi @MaheshShelke,

Try with the attached xaml, I am splitting the strings into 250 characters lengh, you can change that variable size in the variable section to 4000 and then try with your string. The split output strings will be added into a collection.

SplitStringIntoChunks.xaml (7.1 KB)

1 Like

@MaheshShelke
For calcualtion can help:

  • integer division
  • Modulo operation

grafik

till 4000 we cannot relybut can check this char count.
with more then 4000 char we can calculate the no of split with the integer division expressed with a backslash

for the length of the substring we do use the MOD (will give 0 for 4000,8000, x*4000) and do know how many chars we do have in the segment

1 Like

Thanks for the solution, however if the 250th word is not a space then it will break the word and paste the other part in second iteration. In this string the last word is in first iteration is “of” if i changed it to “offset” then it will break the same and it will ignore the “off” and in second iteration it will paste the “set”.

So here can i check if the last 250th position if it is not a “space” then it should get the first part of string till one space before the last space position and then the remaining one in the next iteration.

Thanks in advance

@MaheshShelke,

Try with this one,
SplitStringIntoMeaningfulChunks.xaml (8.3 KB)

Thanks again, sorry I am now to this, it is not opening due to some missing activity.

“Could not find type ‘InterruptibleWhile’ in namespace ‘http://schemas.uipath.com/workflow/activities’. Row: 85, Column: 6”

I have all required activities loaded. I am using 2019.10.1 version

@MaheshShelke,

Update the packages and try with that. I am using 2020.4 version.

I updated all of them but still the same error i reflecting.