Created
August 8, 2023 03:17
-
-
Save HT2Knock/d7647b9c161a0e7c12c9ff453370b20e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const arr = [ | |
| // List of Valid Email Addresses | |
| "[email protected]", | |
| "[email protected]", | |
| "[email protected]", | |
| "[email protected]", | |
| "[email protected]", | |
| "email@[123.123.123.123]", | |
| "\"email\"@example.com", | |
| "[email protected]", | |
| "[email protected]", | |
| "[email protected]", | |
| "[email protected]", | |
| "[email protected]", | |
| "[email protected]", | |
| "[email protected]", | |
| // "1234567890123456789012345678901234567890123456789012345678901234+x@example.com", | |
| // "[email protected]", | |
| // "[email protected]", | |
| // "[email protected]", | |
| // "[email protected]", | |
| // "[email protected]", | |
| // "[email protected]", | |
| // "[email protected]", | |
| // "[email protected]", | |
| // "[email protected]", | |
| // List of Strange Valid Email Addresses | |
| "much.”more\ unusual”@example.com", | |
| "very.unusual.”@”[email protected]", | |
| "very.”(),:;<>[]”.VERY.”very@\\ \"very\”[email protected]", | |
| // List of Invalid Email Addresses | |
| "ngọc-huỳ[email protected]", | |
| "plainaddress", | |
| "#@%^%#$@#$@#.com", | |
| "@example.com", | |
| "Joe Smith <[email protected]>", | |
| "email.example.com", | |
| "email@[email protected]", | |
| "[email protected]", | |
| "[email protected]", | |
| "[email protected]", | |
| "あいうえお@example.com", | |
| "[email protected] (Joe Smith)", | |
| "email@example", | |
| "[email protected]", | |
| "[email protected]", | |
| "[email protected]", | |
| "[email protected]", | |
| "[email protected]", | |
| // List of Strange Invalid Email Addresses | |
| "”(),:;<>[\]@example.com", | |
| "just”not”[email protected]", | |
| "this\ is\"really\"not\[email protected]", | |
| ] | |
| const nodeEmailValidation = /^[-!#$%&'*+\/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/ | |
| const rfcStandard = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ | |
| const html5 = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; | |
| const currentRegex = /^[A-Za-z0-9-_&\+]+(\.[A-Za-z0-9-_&\+]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,4})$/ | |
| const validList = arr.filter(email => html5.test(email)) | |
| const invalidList = arr.filter(email => !html5.test(email)) | |
| console.log(`Valid List`, validList.length, validList) | |
| console.log(`Invalid List`, invalidList.length, invalidList) | |
| const diffList = arr.filter(email => html5.test(email) && !validList.includes(email)) | |
| console.log(`Diff List`, diffList.length, diffList) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment