title: Bypass default wrapping of ^and $ in ng-pattern
body: <p>Im getting my regex from an API, and they often starts with ^ and ends with $ (for example <code>^-?[0-9]+$</code>). Just putting the regex as a string to ng-pattern results in a <code>Lexer Error</code>, since angular adds the ^ and $ by default on strings.</p>
  
  <p>From <a href="https://docs.angularjs.org/api/ng/directive/ngPattern" rel="nofollow">Angular API reference</a></p>
  
  <blockquote>
    <ul>
    <li>If the expression evaluates to a RegExp object, then this is used directly.</li>
    <li>If the expression evaluates to a string, then it will be converted to a RegExp after wrapping it in ^ and $ characters. For instance,
    "abc" will be converted to new RegExp('^abc$').</li>
    </ul>
  </blockquote>
  
  <p>Very well then, let's try to convert the regex string into a regex object, I thought. So I tried this:</p>
  
  <pre><code>json.data.data[i].validateRegex = new RegExp(json.data.data[i].validateRegex, "g");
  </code></pre>
  
  <p>But it result in another error:</p>
  
  <pre><code>Error: ngPattern:noregexp
  Expected Regular Expression
  Expected {} to be a RegExp but was {}.
  </code></pre>
  
  <p>How can I get my regex to work with ng-pattern? Preferably without removing the ^ and $ from the regex. </p>