Last active
March 15, 2021 11:40
-
-
Save AlexVegner/95bddb992ab27a3c5f298ff8d0b97b29 to your computer and use it in GitHub Desktop.
rfc 5322 official standard email regex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The Official Standard: RFC 5322 | |
final emailRegexp = RegExp( | |
r"^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?)*$"); | |
void main() { | |
[ | |
'alex.v@gmail.com', | |
'v@gmail.com', | |
'v@3.gmail.com', | |
'@3.gmail.com', | |
'3.gmail.com', | |
'v@', | |
].forEach(checkEmail); | |
} | |
checkEmail(String email) { | |
final checkSimbol = emailRegexp.hasMatch(email) ? '\u{2705}' : '\u{274C}'; | |
print('$checkSimbol - $email'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment