So, I want to limit the length of an email address. For example, I want the length of the email address should be less then 20 characters.
let regEx = /[a-zA-Z]([\w]+)@[a-zA-Z]+\.(com)/gim
This is my regex code by which I'm validating an email. I want to limit the length e.g. 20 characters or less. Then I want this regex to match the results from a whole paragraph or strings.
"This first mail address [email protected] shouldn't match because it's too long but this mail [email protected] should be a match from this whole string."
I tried using (?=.{1,20}$)
to limit the length. And it works fine when the mail addresses aren't inside a whole paragraph.
For example, it works when
[email protected] //Doesn't match
[email protected] //Match
But it doesn't match if those emails are inside a whole paragraph. like
"This first mail address [email protected] shouldn't match because it's too long but this mail [email protected] should be a match from this whole string."