Another quick PHP one today. I’ve seen some pretty funky regex in the past when validating an email address, and even then most didn’t follow the RFC. Why bother when PHP can do all the magic for you?
$addresses = array( 'chris@test.com', 'bob', 'som@@', 'tht@co .com'); foreach ($addresses as $address) { echo "{$address} is "; if (filter_var($address, FILTER_VALIDATE_EMAIL)) { echo "valid\n"; } else { echo "invalid\n"; } }