I use the following regex pattern for validating the email address that works fine.
/^[^\@]+@.*\.[a-z]{2,6}$/i
But the problem is I want to generate error if email like [email protected]
are enter. Actually all those emails are invalid which have characters same as before & after **.**
like [email protected]
invalid, [email protected]
invalid
You can use a back-reference in a regexp to test if two parts are the same. In PHP you'd write:
if (preg_match('/^(\w+)\.\1@.*/', $email)) {
echo "That's a spammy name";
}