Last active
February 5, 2019 15:23
-
-
Save vmcilwain/6918762cf40d28f428ff4b23affd4e78 to your computer and use it in GitHub Desktop.
[Ruby] Email address scanner and verify
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
# scan for email addresses | |
text-variable.scan(/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i) | |
=> ['[email protected]', 'user2@domain'] | |
# Verify email addresses | |
a = Mail::Address.new('Foo Bar <[email protected]>') | |
a.address | |
=> "[email protected]" | |
# or | |
a = Mail::Address.new('[email protected]') | |
a.address | |
=> "[email protected]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment