Im trying to detect newlines in PHP and replace them with <br> which are not preceded by </ul>, <ul>or </li>.
te
<ul>
<li>iasd</li>
<li>asd</li>
</ul>
ja
123
should result in
te<br>
<ul>
<li>iasd</li>
<li>asd</li>
</ul>
ja<br>
123<br>
The Regex I came up with so far (^|^.|.[^((\/li>)|<\/ul>|<ul>)])\r?\n works, but also is triggered when there only is a > in front of the new line.
` – Lord Elrond Feb 28 '20 at 06:07
[^)[^\s*(*SKIP)(*F)|$~sm', '
– Wiktor Stribiżew Feb 28 '20 at 08:42', $text)`, see https://3v4l.org/2JnT2