I created regex
that's supposed to move text inide of an adjoining <span>
tag.
const fix = (string) => string.replace(/([\S]+)*<span([^<]+)*>(.*?)<\/span>([\S]+)*/g, "<span$2>$1$3$4</span>")
fix('<p>Given <span class="label">Butter</span>'s game, the tree counts as more than one input.</p>')
// Results in:
'<p>Given <span class="label">Butter's</span> game, the tree counts as more than one input.</p>'
But if I pass it a string where there is no text touching a <span>
tag, it takes a few seconds to run.
I'm testing this on Chrome
and Electron
.