Why doesn't my find and replace code work properly?
<p>I need to find and .replaceWith some text, for example:</p>

<blockquote>
  <p><strong>absdef</strong> replace with <strong>111111</strong></p>
  
  <p><strong>abcdefgiop</strong> replace with <strong>22222222</strong></p>
</blockquote>

<p>But when my text looks like </p>

<blockquote>
  <p>abcdef, abcdefgi</p>
</blockquote>

<p>.replaceWith work poorly for me and I get something like this:</p>

<blockquote>
  <p><strong>111111</strong>, 111111giop</p>
</blockquote>

<p>I use this code:</p>

<pre><code>$("*").contents().each(function() {
    if(this.nodeType == 3)
        this.nodeValue = this.nodeValue.replace("absdef", "111111");
});
//
$("*").contents().each(function() {
    if(this.nodeType == 3)
        this.nodeValue = this.nodeValue.replace("abcdefgiop", "22222222");
});
</code></pre>
