Regular expression for validating email in javascript

You can easily write a custom validator to require a dot in the email domain label, but this does not match what is required by the specification, nor what web browsers do with native validation, so it does not seem appropriate that angular's email validator should do this.

Yes, an email address like "[email protected]" is valid (for applications running INSIDE private domains).

In the below demo the regular expression looks for one or more uppercase or lowercase letters within the character class [A-Za-z], followed with an end of a line anchor $ Some undesired spaces and dashes from the user input can be removed by using the string object replace() method.

The regular expression is used to find the characters and then replace them with empty spaces.

In other words, in order read the character as a dot (i.e. If we did not escape the dot with a backslash (i.e. .) then the regex would search for any single character (excpet a new line character such as \n).