이 그것을 할 수있는 좋은 방법은 아니지만, 하나의 가능한 방법은 @ 기호를 사용하여 주소를 폭발 할 수 있습니다 : 물론
// 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
}
을,이 도메인 또는 이메일 주소가 보장하지 않습니다 기존의 것!
uni.edu
uni.edu.fr
uni.ac.uk
다음 정규 표현식은 이러한 모든 경우에 대해 설명합니다 : 필요에 따라
이
/(\.edu(\.[a-z]+)?|\.ac\.[a-z]+)$/
당신은 정규식에 케이스를 추가 할 수 있습니다
체크 아웃이 두 게시물 : http://stackoverflow.com/questions/5136678/php-validate-email-address-based-on-the-domain-name 및 HTTP : //stackoverflow.com/questions/6609195/parse-rfc-822-compliant-addresses-in-a-to-header – Stegrex
그것은 내게 상실된 것처럼 보입니다. 전자 메일이 어떤 형식을 따르는 지 보장 할 수는 없습니다. 예를 들어, 우리 대학교는 학생들에게 ulaval.ca 이메일 주소를 제공합니다. –