title: How to replace text not within a specific-Tag in JavaScript
body: <p>I have a string (partly HTML) where I want to replace the string <code>:-)</code> into bbcode <code>:wink:</code>. But this replacement should not happen within <code>&lt;pre&gt;</code>, but in any other tag (or even not within a tag).</p>
  
  <p>For example, I want to replace </p>
  
  <pre><code>:-)&lt;pre&gt;:-)&lt;/pre&gt;&lt;blockquote&gt;:-)&lt;/blockquote&gt;
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>:wink:&lt;pre&gt;:-)&lt;/pre&gt;&lt;blockquote&gt;:wink:&lt;/blockquote&gt;
  </code></pre>
  
  <p>I already tried it with the following RegEx, but it does not work (nothing gets replaced):</p>
  
  <pre><code>var s = ':-)&lt;pre&gt;:-)&lt;/pre&gt;&lt;blockquote&gt;:-)&lt;/blockquote&gt;';
  var regex = /:\-\)(?!(^&lt;pre&gt;).*&lt;\/pre&gt;)/g;
  var r = s.replace(regex, ':wink:');
  </code></pre>
  
  <p>Can someone please help me? :-)</p>