I am having problem in validating email address with regular expression.The code is seems to works fine until user put some long characters separated by(.dot) at end.Code is
if(preg_match('~^\b[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-z]{2,4}+\b$~',$_POST["email"]))
{
$valid ="valid";
}
else
{
$valid ="invalid";
}
Problem comes when user put something like ksdlk@gll.lik.ij.lio.lk.gr it returns "valid". How to deal with last characters, that would only allow 4,5 characters from @ like ".com"or ".co.uk".
Thanks in advance