Hackerss.com is a community of amazing hackers

Hackerss is a community for developers, data scientitst, ethical hackers, hardware enthusiasts or any person that want to learn / share their knowledge of any aspect of digital technology.

Create account Log in

Posted on

Php Validate email adress using regex

function validateEmail($email) {
  $pattern = '/^[a-zA-Z0-9._-][email protected][a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/';
  if (preg_match($pattern, $email)) {
    return true;
  } else {
    return false;

$result = validateEmail('[email protected]');

echo $result; //true

Enter fullscreen mode Exit fullscreen mode

Top comments (0)