1

如何修改下面的 preg_match 函数以允许所有以 harvard.edu 电子邮件地址结尾的电子邮件地址,而不是仅以 @college.harvard.edu 结尾的电子邮件地址?

if(!preg_match("/@college\.harvard\.edu$/", $_POST["username"]))
    {
        apologize("You must provide a Harvard email to register.");
    }  
4

1 回答 1

6
if(!preg_match("/@.*harvard\.edu$/", $_POST["username"]))
{
    apologize("You must provide a Harvard email address to register.");
}
于 2012-12-06T23:40:54.027 回答