title: extjs 4.2 - replace substring, but avoid changing tags
body: <p>In a given string, e.g. <code>"This &lt;TERM&gt;is&lt;/TERM&gt; my question &lt;TERM&gt;for&lt;/TERM&gt; you"</code>, I need to replace a substring.</p>
  
  <p>Goal: surround substring with <code>&lt;MARK&gt;</code>-Tags for highlighting.</p>
  
  <p><strong>Example</strong>:</p>
  
  <p>substring: 'e'</p>
  
  <p>desired result: <code>This &lt;TERM&gt;is&lt;/TERM&gt; my qu&lt;mark&gt;e&lt;/mark&gt;stion &lt;TERM&gt;for&lt;/TERM&gt; you</code></p>
  
  <p>actual result: <code>This &lt;T&lt;mark&gt;E&lt;/mark&gt;RM&gt;is&lt;/T&lt;mark&gt;E&lt;/mark&gt;RM&gt; my qu&lt;mark&gt;e&lt;/mark&gt;stion &lt;T&lt;mark&gt;E&lt;/mark&gt;RM&gt;for&lt;/T&lt;mark&gt;E&lt;/mark&gt;RM&gt; you</code></p>
  
  <p>How can I prevent the pseudoTags <code>&lt;TERM&gt;</code> and <code>&lt;/TERM&gt;</code> from beeing changed?</p>
  
  <p>Until now, I used this:</p>
  
  <p>according to my example, filterValue would be substring 'e'</p>
  
  <pre><code>var filterStartTag = '&lt;mark&gt;';
  var filterEndTag = '&lt;/mark&gt;';
  var replaceFilterValue = filterStartTag + filterValue + filterEndTag;
  value = value.replace(new RegExp(filterValue, 'gi'), replaceFilterValue);
  </code></pre>
  
  <p>I need to find a solution where also substrings like "t", "te", "erm" (and so on) can properly be replaced.</p>
  
  <p>Any help would be highly appreciated.</p>