title: Less or greater than characters except html tags?
body: <p>I need to replace less or greater than(<code>&lt; &gt;</code>) characters, but keep any html tags(simple tags will do like <code>&lt;b&gt;text&lt;/b&gt;</code> without arguments).
  So the input below:</p>
  <pre><code>&lt;b&gt;&gt; 0.5 &lt; 0.4&lt;/b&gt; - &lt;&gt;
  </code></pre>
  <p>Should be:</p>
  <pre><code>&lt;b&gt;&amp;gt; 0.5 &amp;lt; 0.4&lt;/b&gt; - &amp;lt;&amp;gt;
  </code></pre>
  <p>All I managed to find and edit now is this expr:</p>
  <pre><code>&lt;\/?[a-z][a-z0-9]*[^&gt;\s]*&gt;|([&lt;&gt;])
  </code></pre>
  <p>It groups the <code>&lt;</code> and <code>&gt;</code> characters but it also matches tags witch I don't need to replace</p>
  <p><strong>UPD:</strong>
  Thanks to <em>@Sree Kumar</em>, here's the final functions:</p>
  <pre><code>String.prototype.replaceAt = function (index, char) {
      let arr = this.split('');
      arr[index] = char;
      return arr.join('');
  };
  
  String.prototype.escape = function () {
      let p = /(?:&lt;[a-zA-Z]+&gt;)|(?:&lt;\/[a-zA-Z]+&gt;)|(?&lt;lt&gt;&lt;)|(?&lt;gt&gt;&gt;)/g,
          result = this,
          match = p.exec(result);
  
      while (match !== null) {
          if (match.groups.lt !== undefined) {
              result = result.replaceAt(match.index, '&amp;lt;');
          }
          else if (match.groups.gt !== undefined) {
              result = result.replaceAt(match.index, '&amp;gt;');
          }
          match = p.exec(result);
      }
      return result;
  };
  </code></pre>