I know this have been similarly asked multiple times, but regex is somehow tricky and I can't find my particular need on other answers.
I have this html string:
... other content<div><br></div> <div>End of useful html string</div> <div><br></div> <div><br></div> <div><br></div>
and this regex pattern:
/<div><br><\/div>/gi
It matches all <div><br><\/div>
. Really simple up to that point.
But the thing is that I would like to remove only that pattern after the end of the useful html string, in other words, when the pattern starts to be only <div><br></div> <div><br></div> <div><br></div>
and nothing before <div>End of useful html string</div>
Just to clarify, there maybe lots of additional <div><br></div>
at the end.
This is to remove the new lines at the end of contentEditable div.