I have a string and I want to divide it into an array of strings that will be put on separate lines, where each string (or line) is not more than a given length. Each string should only be split on characters that normally allow line breaks, such as spaces.
For example, "Hello World" with a maxLength of 5 would be split into ["hello", "world"]. "Reference site about Lorem Ipsum" with a maxLength of 14 would be split into ["Reference site", "about Lorem", "Ipsum"].
Is there a built-in function to do this?