Regular expressions are rarely used, so I’m here to ask you for advice. . .
var reg=/<p><br><\/p><p><br><\/p><p><br><\/p>/;
var con=$('#content').html().replace(reg, '<p><br></p>');
That is, I want to match the consecutive /<p>
</p> into one, so as not to see all line breaks. Now, three reg matches are replaced with one p tag. This is problematic. . . . . . For example, if I have five p tags, he will output three p tags. . . Because after matching the first three, he will continue matching from the second p tag! Asking for help
var reg = /<p>|</p>/g;
var con = $('#content').html().replace(reg, '');
con = '<p>' + con + '</p>';