JSFiddle - React, Tailwind, and code Playground
HTML
<div id="output"></div>
JavaScript
// Note: in order to load the html into the dom it needs a root. I'm using `div`:
var input = '<div>' +
'<p>Blah<br><br><br></p> becomes <p>Blah</p>' +
'<p><br></p> stays the same.' +
'</div>';
// Load the html into a jQuery object:
var $html = $(input);
// Get all the `<br>`s within `p`s that are not the only-child:
var $lastBreaks = $html.find('p>:last-child:not(:only-child)').filter('br');
// Remove any immediately preceding `br`s:
$lastBreaks.prevUntil(':not(br)').remove();
// Remove the last `br`s themselves
$lastBreaks.remove();
// Output:
$('#output').text($html.html());