V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
linkdesu
V2EX  ›  编程

Modern Email Validation Regex

  •  
  •   linkdesu · Jul 24, 2018 · 3495 views
    This topic created in 2834 days ago, the information mentioned may be changed or developed.

    今天突然来了兴致写了个邮箱验证正则,编程这么多年都很难的写一次这个验证,还多半是复制粘贴了事,今天一看 wiki 才发现原来邮箱名支持的字符挺多的,所以写了个新的正则,欢迎手里有砖的朋友来拍一下指点一下:

    正则(js 语法):

    /^(?:[\w\.\!\#\$\%\&\'\*\+\-\/\=\?\^_`\{\|\}\~]+|\".+\")@(?:[\w\-\.]+|\[[\da-fA-F\:]+\])$/
    

    Gist 地址:

    https://gist.github.com/linkdesu/f428ef14b634299e51afa2b7e113cd3f

    2 replies    2018-07-24 20:41:39 +08:00
    34C
        1
    34C  
       Jul 24, 2018 via iPhone
    我一般就检查一下有 @ 有 . 就是了,邮件发不过去有什么损失是用户的损失,或者可以检查一下 dns 记录
    ReysC
        2
    ReysC  
       Jul 24, 2018   ❤️ 1
    其实有个不错的:

    http://emailregex.com/
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1401 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 23:54 · PVG 07:54 · LAX 16:54 · JFK 19:54
    ♥ Do have faith in what you're doing.