title: replace a pattern with URL
body: <p>The idea is taken from <a href="https://stackoverflow.com/questions/37684/how-to-replace-plain-urls-with-links">here</a></p>
  
  <p>I have the following code:</p>
  
  <pre><code>myApp.filter('parseUrlFilter', function () {
  var urlPattern = /^E\d{5}-\d{2}$/;
  return function (text, target) {
      return text.replace(urlPattern, '&lt;a target="' + target + '" href="http://somepage.com?number=$&amp;"&gt;$&amp;&lt;/a&gt;') + " | ";
  };
  });
  </code></pre>
  
  <p>I'm still trying to understand how this code exactly works but it does not convert the text to URL.</p>
  
  <p>Like <code>E12345-01</code> does not become <code>somepage.com?number=E12345-01</code></p>
  
  <p>I think I'm missing something about how the regex works here. Any help will be appreciated.</p>
  
  <p>Edit: added <a href="http://plnkr.co/edit/uhq2d2LQQ3LAqX2fCQrl?p=preview" rel="nofollow noreferrer">plnkr</a> with somewhat working answer of machinehead115</p>