JSFiddle - React, Tailwind, and code Playground

HTML

<p style="border: 1px solid red;">
<br>
<br>
JQuery problems again...
<br>
<br>
Why me...?
<br>
<br>
</p>

JavaScript

$('p').each(function(){
    var h = $(this).html().trim();
    
    // remove <br> tags before text
    while (h.match(/^<br ?\/?>/gi)) h = h.replace(/^<br ?\/?>/gi, '').trim();
    
    // remove <br> tags after text
    while (h.match(/<br ?\/?>$/gi)) h = h.replace(/<br ?\/?>$/gi, '').trim();
    
    $(this).html(h);    
});