title: Replace word in text BUT only if it is not contained in a specific pattern
body: <p>I want to replace some word in a text BUT only if it is not contained in a specific pattern.
  Specifically, in the text: <strong>myWord class = 'someClass'&gt;myWord&lt;/span&gt; myWord</strong>
  the word I want to replace is <strong>myWord</strong> BUT only if it is not contained in the following pattern of the text: <strong>class = 'someClass'&gt;myWord&lt;/span&gt;</strong>. Could you please someone help me.</p>
  <p>Input
  <em><strong>myWord</strong> class = 'someClass'&gt;<strong>myWord</strong>&lt;/span&gt; <strong>myWord</strong></em></p>
  <p>Expected Output
  <em><strong>myWordReplaced</strong> class = 'someClass'&gt;<strong>myWord</strong>&lt;/span&gt; <strong>myWordReplaced</strong></em></p>
  <pre><code>&lt;div id=&quot;myView&quot;&gt;&lt;/div&gt;
  
  &lt;script&gt;
      vText = &quot;myWord class = 'someClass'&gt;myWord&lt;/span&gt; myWord&quot;; 
      vWord = &quot;myWord&quot;;
      vRegExp = `(class = 'TransparentAndUnderline'&gt;.*)${vWord}(.*&lt;\/span&gt;)`;
      const vNewRegExp = new RegExp(vRegExp, 'gi');
  
      vText = vText.replace(vWord, function() {
          if (!vNewRegExp.test(vText)) { // If it is not contained in the pattern, replace
              return 'myWordReplaced';
          } else {// Otherwise, do nothing
              return;
          }
      })
  
      document.getElementById(&quot;myView&quot;).innerHTML = vText;
  &lt;/script&gt;
  </code></pre>