Java splitting long String text to blocks in String array using Regex

Viewed 30

I've been trying to split long text input of type of String, by using Regex, and putting each block as a new string in array of strings. The problem I'm having is that it finds all matches only when the block is in the same line. I want to enhance my Regex expression by including newlines delimiters which I probably miss, and I don't know where exactly should I insert it.

My regex:

(?<=start)(.*)(?=end)

An example of my text input:

start
   first block here
end
start
   second block here
end
start
   third block here
end  

The result should be an array that consists of 3 blocks: first block here, second block here, third block here

0 Answers
Related