Email validation using regular expression in PHP

后端 未结 11 1547
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-30 01:38

I am pretty much new with regular expression. I am developing a project in PHP and i need to validate email address. After searching in this site and google i found the fol

11条回答
  •  半阙折子戏
    2020-11-30 02:25

    try this regx it would work fine

    /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/  
    

    or php filter filter_var

     filter_var($email, FILTER_VALIDATE_EMAIL)
    

    like

    if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
         //yup its valid email
    }
    

提交回复
热议问题