Add Comments To Regex With Free-Spacing
simple_email = /\A.+@.+\z/xsimple_email = /
\A # beginning of the string
.+ # any opening characters
@ # the email's `@` symbol
.+ # the rest of the email
\z # the end of the string
/xtest_emails = [
'taco',
'email@example.com',
'more.complex+email@example.com',
'@'
]
test_emails.each do |email|
if (simple_email =~ email) == 0
puts "#{email} looks like an email"
else
puts "#{email} may not be an email"
end
endLast updated