Reputation: 532
We have special requirements for our email verification. We want to allow the following:
.-_
(period, hyphen and underscore).So far I've managed to figure our how to check for alphanumeric: [^A-Za-z0-9 ]
But I'm completely stuck on the hardest part - the middle section. Thanks.
Upvotes: 1
Views: 67
Reputation: 39456
Before you go down the path of email validation with regex, have you tried filter_var()
with FILTER_VALIDATE_EMAIL
?
if(filter_var($email, FILTER_VALIDATE_EMAIL) !== false)
{
// Valid email.
}
Upvotes: 1