There is no great way to do this, but one possible way would be to explode the address using the @ symbol:
// Split the email address into 2 values of an array using the @ symbol as delimiter. $emailParts = explode('@', $theEmailAddress); // If the second part (domain part) contains .edu, period, country code or just .edu, then allow signup. if (preg_match('/\.edu\.[^.]+$/i', trim($emailParts[1])) || preg_match('/\.edu$/i', trim($emailParts[1]))) { // Use the above if you are assuming that the country codes can be any number of characters. If you know for sure country codes are 2 chars, use this condition: // (preg_match('/\.edu\.[^.]{2}$/i', trim($emailParts[1])) || preg_match('/\.edu$/i', trim($emailParts[1]))) // Allow signup }
Of course, this does NOT guarantee that the domain or email address is already existing!
source share