title: replace \n and \r\n with <br /> in java
body: <p>This has been asked several times for several languages but I can't get it to work.
  I have a string like this</p>
  
  <pre><code>String str = "This is a string.\nThis is a long string.";
  </code></pre>
  
  <p>And I'm trying to replace the <code>\n</code> with <code>&lt;br /&gt;</code> using</p>
  
  <pre><code>str = str.replaceAll("(\r\n|\n)", "&lt;br /&gt;");
  </code></pre>
  
  <p>but the <code>\n</code> is not getting replaced.
  I tried to use this <a href="http://www.regexplanet.com/simple/index.html" rel="noreferrer">RegEx Tool</a> to verify and I see the same result. The input string does not have a match for <code>"(\r\n|\n)"</code>. What am i doing wrong ?</p>