I have a line that is a fragment of a book (about 1 chapter) this line is one line. I would like to make a new line at the end of each sentence
I solved it with not very complicated code
text = text.replaceAll("\\.","\\.\n"); //same for ? same for !
and, of course, this does not give very pleasant results. I don't need this to be perfect, but better I can get it better.
I want to at least check the following before creating a new line character:
the word before the . is longer then 2 characters there are no dots before the . in the same "word" the character before the . is not a number the character after the dot (and possibly a whitespace after that dot) is not a (
Any other suggestions would be really appreciated, as well as the actual code that will do this.
Similar question: Here
Update:
Although my list of priorities is small, because my book does not contain many direct quotes or direct speeches, but the rule that processes sentences inside them will also be fine so that sentences from the same qoute do not include new lines
source share