Find & Replace with wrapped superscript

by ashleycam3ron

HTML

<div>Text ™, ®, ©</div>
<div>
    <p>™</p>
    <b>Rob®</b>
</div>

JavaScript

$('body :not(script,sup)').contents().filter(function() {
    return this.nodeType === 3;
}).replaceWith(function() {
    return this.nodeValue.replace(/[™®©]/g, '<sup>$&</sup>');
});