All pastes #361333 Raw Edit

Something

public text v1 · immutable
·published 2007-02-18 02:13 UTC
rendered paste body
/* Used to check if an email is valid (or acceptable for my purposes */

The goal of this code is to ensure $email is structured as follows:
  1) MAILBOX NAME (min 3 characters)
    (alphanumeric|alphanumeric, underscore, period or hyphen|alphanumeric)
  2) @ Symbol
  3) DOMAIN (min 3 characters)
    (alphanumeric|alphanumeric or hyphen|alphanumeric)
  4) EXTENSION (.com|.net|.org)

if ( preg_match("/^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9]+@+[a-zA-Z0-9]+[a-zA-Z0-9-]+[a-zA-Z0-9]+\.(com|net|org)$/", $email ) > 0 ) {
	echo "Good";
} else {
	echo "Bad";
}