title: How to replace text using regex with condition?
body: <p>I want to replace a link as plain text format to html format.</p>
  
  <p>But I got the issue that, I don't know how to prepend the <code>http://</code> prefix for the new replacement if in the original link does not exist.</p>
  
  <pre><code>var text        = "google.com and http://google.com";
  var pattern     = /(\b((https?)\:\/\/)?[A-Za-z0-9]+\.(com|net|org))/ig;
  text            = text.replace(pattern,"&lt;a href='$1'&gt;$1&lt;/a&gt;");
  </code></pre>
  
  <p>I meant:   </p>
  
  <ol>
  <li>If: <code>google.com</code> will be replaced <code>&lt;a href="http://google.com"&gt;google.com&lt;/a&gt;</code>  </li>
  <li>If: <code>http://google.com</code> will be replaced <code>&lt;a href="http://google.com"&gt;http://google.com&lt;/a&gt;</code></li>
  </ol>