title: Replace "<" and ">" with "&lt;" and "&gt;"
body: <p>I want to replace <code>&lt;</code> and <code>&gt;</code> with <code>&amp;lt;</code> and <code>&amp;gt;</code> if it is not a part of an html tag.
  Input will be a string that may contain certain html tags. It can also contain less than &amp; greater than signs (">" "&lt;").
  For example:</p>
  
  <pre><code>String example1 = "-&gt; &lt;b&gt; Bold &lt;/b&gt; &lt;-";
  String example2 = "&lt; &lt;i&gt; Italic &lt;/i&gt; &gt;"
  String example3 = "&lt;i&gt;foo &gt;&gt; &lt;/i&gt;"
  </code></pre>
  
  <p>As output I want to get:</p>
  
  <pre><code>String output1 = "-&amp;gt; &lt;b&gt; Bold &lt;/b&gt; &amp;lt;-";
  String output2 = "&amp;lt; &lt;i&gt; Italic &lt;/i&gt; &amp;gt;";
  String output3 = "&lt;i&gt;foo &amp;gt;&amp;gt; &lt;/i&gt;";
  </code></pre>
  
  <p>So <code>replaceAll</code> doesn't work, I have to use a regular expression match I guess. Any ideas? Some other way?</p>
  
  <p><strong>Note1:</strong> 3rd party library is not an option because of certain project requirements.<br>
  <strong>Note2:</strong> We support only a subset of HTML tags(text styling tags: italic, underline, bold etc.)</p>