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 m123456789999@xmail.com shouldn't match because it's too long but this mail m1234@xmail.com 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
m123456789999@xmail.com //Doesn't match
m1234@xmail.com //Match
But it doesn't match if those emails are inside a whole paragraph. like
"This first mail address m123456789999@xmail.com shouldn't match because it's too long but this mail m1234@xmail.com should be a match from this whole string."