正则表达式不允许电子邮件中的点位于错误的位置 [英] Regex to don't allow dots in email at wrong position
问题描述
我的正则表达式现在看起来像这样:
/ [a-z0-9。] *(john)[a-z0-9。] * @ mycompany\.com /
唯一的问题,它允许点错误的地方。
我看到有效的这封电子邮件:
john@mycompany.com
smith.john@mycompany.com
john.smith@mycompany.com
但我不应该看到有效的:
john。@ mycompany.com
.john @ mycompany.com
/ ^([a-z0-9] [a-z0-9。] *)?(john)([a-z0-9。] * [a -z0-9])?@ mycompany\.com $ /
这应该确保前后的字符(john)
不要以开始/结束。
I have to validation emails from a company. The regex should validate if it come from the company and could come from John.
My regex looks like this now:
/[a-z0-9.]*(john)[a-z0-9.]*@mycompany\.com/
The only problem, it's allows dots in wrong place. I see valid this emails:
john@mycompany.com
smith.john@mycompany.com
john.smith@mycompany.com
But i shouldn't see valid these:
john.@mycompany.com
.john@mycompany.com
/^([a-z0-9][a-z0-9.]*)?(john)([a-z0-9.]*[a-z0-9])?@mycompany\.com$/
This should make sure that characters before/after (john)
don't start/end with a .
respectively.
这篇关于正则表达式不允许电子邮件中的点位于错误的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!