How to validate non-english (UTF-8) encoded email address in Javascript and PHP?

前端 未结 7 912
无人及你
无人及你 2020-12-06 06:16

Part of a website I am currently working on contains registration process where users have to provide their email address. Just recently I became aware that non-ascii based

7条回答
  •  甜味超标
    2020-12-06 06:37

    As offered by Mario, playing around a bit, I came up with the following regex to validate non-standard email address:

    ^([\p{L}\_\.\-\d]+)@([\p{L}\-\.\d]+)((\.(\p{L}){2,63})+)$
    

    It would validate any proper email address with all kind of Unicode letters, with TLD limitations from 2 to 63 characters.

    Please check it and let me know if there are any flaws.

    Example Online

提交回复
热议问题