title: Java regex string replace
body: <p>I am trying to write regex for replacing string.</p>
  
  <p>There are string examples:</p>
  
  <p><code>I am student.</code></p>
  
  <p><code>I &lt;a href="am.html"&gt;am&lt;/a&gt; student.</code></p>
  
  <p>I want to write regex which will replace "am" with <code>&lt;a&gt;</code> html tag, and get second string as result of replacing the first string.</p>
  
  <p>Problem is nesting in quotes and text inside tag. </p>
  
  <p>For example if I try to replace string "am" in this example:</p>
  
  <p><code>I &lt;a href="am.html"&gt;am&lt;/a&gt; am student.</code></p>
  
  <p>Result should be:</p>
  
  <p><code>I &lt;a href="am.html"&gt;am&lt;/a&gt; &lt;a href="am.html"&gt;am&lt;/a&gt; student.</code></p>
  
  <p>Thanks in advance!</p>