I need to separate a text into parts (array). Text similar to this:
Lorem ipsum pain sit amet, consectetur adipiscing elit. Donec eget magna faucibus, fermentum nibh dapibus, dictum.
Integer eleifend lorem nec velit tincidunt, eu elementum nulla cursus.
[Separator1] Donec arcu quam, posuere non molestie eu, bibendum non enim. [/ Separator1]
Phasellus ante nulla, euismod vitae magna porta, iaculis posuere velit.
[Separator2] Mauris sed fermentum justo, at hendrerit sem. [/ Separator2]
Cras dapibus magna vel urn facilisis, thirsty fringilla urn interdum. In I will thirst nibh sed pharetra.
I've done it with preg_match_all in the following way:
$re = '/\[Separador1\](.*?)\[\/Separador1\]|\[Separador2\](.*?)\[\/Separador2\]/ms';
preg_match_all($re, $content, $matches, PREG_SET_ORDER, 0);
However the result contains only what is inside [Separator1] ... [/ Separator1] and [Separator2] ... [/ Separator2] but I need the result in array also to contain the text that is on top of it. [Separator1] and [Separator2]