员工的电子邮件ID有限制 [英] Email Id’s of Employee has restrictions
问题描述
员工的电子邮件ID具有不应该以数字开头的限制,在导入期间不应该有多个特殊字符(如点,下划线)。只允许电子邮件的基本格式。
我使用这个正则表达式:
^ [az] [az | 0-9 |] *([_] [az | 0-9] +)*([。] [az |+
@0-9] +([_] [az | 0-9] +)*)?@ [ az] [az | 0-9 |] * \。([az]+
@[az | 0-9] *(\。[az] [az | 0- 9] *)?)$
但它提供更多_空格字符。
使用^ [az] [az | 0 -9 |] *([_] [AZ | 0-9] +)([] [AZ | 0-9] +([_] [AZ |?0-9] +))@ [AZ] [ az | 0-9 |] * \。([az] [az | 0-9] *(\。[az] [az | 0-9] *)?)$
令人满意的是rahu_l.madarap_u@gmail.com
但是我只需要一个{_}字符
但它提供更多_空格字符。
使用^ [az] [az | 0- 9 |] *([_] [AZ | 0-9] +)([] [AZ |。0-9] +([_] [AZ?| 0-9] +))@ [AZ] [AZ | 0-9 |] * \([AZ] [AZ | 0-9] *(\ [AZ] [AZ |?0-9] *))。
令人满意的rahu _l.madarap_u@gmail.com
但是我只需要一个{_}字符
首先,你的正则表达式过于复杂并且没有不太适合域名标准。
- 你有|
在括号内的字符类中的管道,是不必要的,因为括号内的所有内容都已经是交替。此外,这意味着您无意中匹配了|
字符!
- 下划线_
字符不需要在括号中 - 它不是正则表达式的特殊字符。也许你只是为了可读性而这样做?
- 域名不必以字母开头,并且可以包含破折号。您可能无法将某些有效的电子邮件地址与您的限制相匹配。
其次,我不确定您使用的语言是什么,但这里有两种不同的解决方案,根据你是否有可用的负面预测。
使用否定前瞻:
^(?!(。* [_。]){ 2 }。* @)[az] [a-z0- 9 ._] * @([ - a-z0- 9 ] + \。)+ [a-z0- 9 跨度>] +
Email Id’s of Employee has restrictions like should not start with number , should not have more than one special character (like dot , underscore) during import. Allows only the basic format of email.
I am used this regular expression:
^[a-z][a-z|0-9|]*([_][a-z|0-9]+)*([.][a-z|" +
@"0-9]+([_][a-z|0-9]+)*)?@[a-z][a-z|0-9|]*\.([a-z]" +
@"[a-z|0-9]*(\.[a-z][a-z|0-9]*)?)$
But it is giving more _ spacial characters.
Am used ^[a-z][a-z|0-9|]*([_][a-z|0-9]+)([.][a-z|0-9]+([_][a-z|0-9]+)?)@[a-z][a-z|0-9|]*\.([a-z][a-z|0-9]*(\.[a-z][a-z|0-9]*)?)$
it is satisfying rahu_l.madarap_u@gmail.com
but i need to take only one { " _ " } character
But it is giving more _ spacial characters.
Am used ^[a-z][a-z|0-9|]*([_][a-z|0-9]+)([.][a-z|0-9]+([_][a-z|0-9]+)?)@[a-z][a-z|0-9|]*\.([a-z][a-z|0-9]*(\.[a-z][a-z|0-9]*)?)
it is satisfying rahu_l.madarap_u@gmail.com
but i need to take only one { " _ " } character
First of all, your regex is overly complicated and doesn't quite fit standards for domain names.
- You have|
pipes inside of bracketed character classes, which are unnecessary since everything inside brackets is already an alternation. Furthermore, it means that you have inadvertently matched the|
character!
- The underscore_
character does not need to be in brackets - it is not a special character for regex. Maybe you did that just for readability?
- Domain names do not have to start with letters, and can contain dashes. You may not match some valid email addresses with your restrictions in place.
Second, I'm not sure what language you are using, but here are two different solutions, based on whether you have negative lookaheads available.
Using negative lookaheads:
^(?!(.*[_.]){2}.*@)[a-z][a-z0-9._]*@([-a-z0-9]+\.)+[a-z0-9]+
这篇关于员工的电子邮件ID有限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!