Skip to content

Instantly share code, notes, and snippets.

@vmcilwain
Last active February 5, 2019 15:23
Show Gist options
  • Save vmcilwain/6918762cf40d28f428ff4b23affd4e78 to your computer and use it in GitHub Desktop.
Save vmcilwain/6918762cf40d28f428ff4b23affd4e78 to your computer and use it in GitHub Desktop.
[Ruby] Email address scanner and verify
# 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