| |
| Validate an email address | |
|
def probably_valid?(email)
valid = '[A-Za-z\d.+-]+' # Commonly encountered email address characters
(email =~ /#{valid}@#{valid}\.#{valid}/) == 0
end
#These give the correct result.
probably_valid? 'jo[email protected]' # => true
probably_valid? 'joe@examplecom' # => false
|
| | | | Related examples in the same category |
|