Home > Mobile >  What is the email validation regex used by Angular built-in email validator?
What is the email validation regex used by Angular built-in email validator?

Time:12-06

We're using Angular v12 built-in email validator and we want to use the same regex pattern it uses in other places to be aligned with same email validation logic, what is the regex pattern? I couldn't find it in Angular's Github, a reference to the pattern in the source code would be great too!

CodePudding user response:

use this pattern in .ts file: ('^[a-zA-Z0-9._-] @[a-zA-Z0-9.-] [.][a-zA-Z]{2,4}$')

CodePudding user response:

/^[\w-\.] @([\w-] \.) [\w-]{2,4}$/
  • Related