title: AngularJS - Remove leading and trailing whitespace from input-box using regex
body: <p>I am writing a regular expression(regex) for adding multiple email ids in an input box with following conditions:</p>
  
  <ol>
  <li>Multiple email ids must be separated with comma <code>,</code></li>
  <li>Need to have atleast one email id</li>
  <li>There should not be any whitespaces in input field.</li>
  </ol>
  
  <p>So i created this regex: </p>
  
  <pre><code>^(([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+([,.](([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+)*$
  </code></pre>
  
  <p>I tested it in regex101.com and its working like a charm <a href="https://regex101.com/r/bU7rU8/1">https://regex101.com/r/bU7rU8/1</a></p>
  
  <p>But when i integrate it with code, it works, <strong>but fails on leading and trailing whitespace</strong>.</p>
  
  <p>Here is the demo link: <a href="http://jsfiddle.net/2G8gA/330/">http://jsfiddle.net/2G8gA/330/</a> </p>