I have a large string (with text).
I need to split it into a few pieces (according to max chat limit), run some operations with them independently, and in the end merge the result.
A pretty simple task.
I’m just looking for an algorithm that will split text naturally. So it doesn’t split it on fixed sized substrings, and doesn’t cut the words in half.
For example (* is the 100th char, max char limit is set to 100):
….split me aro*und here…
the 1st fragment should contain: …split me
the 2nd fragment should be: around here…
Working in Java btw.
You could use lastIndexOf(String find, int index).
And
Prints