I am writing a regular expression(regex) for adding multiple email ids in an input box with following conditions:
- Multiple email ids must be separated with comma
, - Need to have atleast one email id
- There should not be any whitespaces in input field.
So i created this regex:
^(([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})+)*$
I tested it in regex101.com and its working like a charm https://regex101.com/r/bU7rU8/1
But when i integrate it with code, it works, but fails on leading and trailing whitespace.
Here is the demo link: http://jsfiddle.net/2G8gA/330/
ng-trim="false". Have a look at this fiddle. Is it what you need?