I have this code that checks if an email is valid:
$email = "[email protected]"; $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>[email protected]</p> </body> </html> How could I check if that string has an email or not? (since it does not work with the above code)