I'm trying to get starting and ending index positions of paragraphs in an assortment of text. I'm using the Pattern and Matcher classes and am having some issues understanding how to set my pattern up. Currently I'm using
Pattern p = Pattern.compile(".+", Pattern.MULTILINE);
to separate the paragraphs. This works, however the new line character gets stripped out. Is there a way to keep the newline character? I would like...
"This is paragraph1\nThis is paragraph2\nThis is paragraph3\n"
to separate to something like this...
"This is paragraph1\n"
"This is paragraph2\n"
"This is paragraph3\n"
As I said before, right now the new lines get stripped which means my indices for paragraphs after the first to be off. I think the Pattern.MULTILINE is stripping out the newline as it accepts everything before it so I think I would need to change that and update my regex.
Thoughts?