Skip to content

Instantly share code, notes, and snippets.

@andreaseriksson
Created January 21, 2014 10:24
Show Gist options
  • Save andreaseriksson/8537613 to your computer and use it in GitHub Desktop.
Save andreaseriksson/8537613 to your computer and use it in GitHub Desktop.
Emails regex matching
emails = %w/ [email protected] [email protected] 23214sdj^as
[email protected] /
pattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$/
emails.each do |email|
if email.match pattern
puts "#{email} matches"
else
puts "#{email} does not match"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment