I guess it's trivial but I'm struggling with the following situation:
String (HTML delievered as text):
text<br>text<br><ul><li>text</li></ul><br>
Now I need to replace every text<br> with <div>text</div>
except if text is inside <li>/<ul>.
.replace(/(.*?)<br>/g, '<div>$1</div>')
This works fine but how to prevent <ul><li>text</li></ul><br> from beeing replaced?