How to make append line in a text for each 89.char if it is whitespace or the other way is last whitespace before 89.char

Hello,

I am new to uipath. I have a long text file and i need to write them line by line. Each line must be max. number of 90 chars and i need to split them from whitespaces. I assigned text as char array and i check if charArray(89) is whitespace or not but if it 89.char is not whitespace then it must look for the last whitespace before 89.char.

For example :

INPUT TEXT : “Hello I’m Robot produced by uipath”

OUTPUT TEXT :
“Hello
I’m Robot
produced by
uipath”

WRONG OUTPUT :
“Hel
lo I’m Ro
bot produ
ced by uip
ath”

I think my starting steps are true with charArray but next up what should i do?

Thanks,

if you want split with white space
stringarray = split(string," ")

to split with new line
stringarray = split(string,Environment.newline)

Thank for your reply,

I think split(string," ") will split the text from all the whitespaces. Am i right?

If yes this won’t be a solution for my problem at all. I need the split the text from each 89.chars if the 89.char is whitespace if not a whitespace then i need to split it from the last whitespace before 89.char (for example 81.char)