This is my attempt to improve on the regex that match 99.99% of email from https://www.regular-expressions.info/email.html
This is a practical implementation of RFC 5322 where I omitted IP addresses, domain-specific addresses, the syntax using double quotes and square brackets.
- Maximum length of email address is 254
- Maximum length of the local part is 64
- The local part must not contain double dots and must not start or end with a dot.
- Maximum length of each domain label is 63
- The domain part must contain at least 2 domain labels, each domain label must not start or end with a hyphen. Domain labels are separated by 1 dot.
- The top level domain must contain only alphabet letters and must contain at least 2 letters.