I need regexp for match all newlines to first match.
Example text:
<p>[Block 1]</p>
<h4>Heading</h4>
<p>Dolor</p>
<p>Ipsum</p>
<p>Lorem</p>
<p>[Block2]</p>
<table>
<tbody>
<tr>
<td>Example</td>
</tr>
<tr>
<td>Example</td>
</tr>
</tbody>
</table>
I wrote this regexp
/<p>\[(.*)\]<\/p>(.*?)/gm
But this regexp doesn't match newlines to first match. I need array:
[0] =>
[0]=>'Block 1';
[1]=>'...Html code... before next [block #]';
[1] =>
[0]=>'Block 2';
[1]=>'...Html code... before next [block #]';
\[(.*?)]<\/p>(.*?)(?=
\[.*?]<\/p>|\z)/s'`, see [demo](https://regex101.com/r/WcbDZn/1).
– Wiktor Stribiżew Dec 12 '19 at 09:35