regex 电子邮件的正则表达式模式

14ifxucb  于 2023-08-08  发布在  其他
关注(0)|答案(1)|浏览(175)

我搜索了很多正则表达式模式,这对我来说很方便。我找不到
这是我的条件

1. email should not contain any space or special characters(excep @ and .)
2. email should not start with dot(.) or should not end with .(before @ symbot)
3. two dots should not come near.
4. @ symbol should not repeat.

字符串
这里有一些有效和无效的电子邮件ID,

firstname@gmail.com -- valid
firstname.@gmail.com -- invalid(dot and @ should not come closer)
firstname..lastname@gmail.com --invlid(two dots should not come closer)
firstname#lastname@gmail.com -- invalid(should not contain any special characters appart @ and .)
frist1991@gmail.com -- valid
first name@gmai.com -- invalie( should not allow any spaces)
.fristname@gmail.com --invalid(should not start with .)


我发现了很多电子邮件的正则表达式模式。但没有满足我的条件
先谢谢你,

j13ufse2

j13ufse21#

这将工作:

^[a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*@[a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*$

字符串
https://regex101.com/r/nen2SZ/1

相关问题