I have this code that checks if an email is valid:
$email = "abc123@sdsd.com";
$regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/';
if (preg_match($regex, $email)) {
echo $email . " is a valid email. We can accept it.";
} else {
echo $email . " is an invalid email. Please try again.";
}
assuming that I have the following string below:
<html>
<body>
<p>abc123@sdsd.com</p>
</body>
</html>
How could I check if that string has an email or not? (since it does not work with the above code)