我是正则表达式的新手,我在VBscript函数中有以下模式来验证电子邮件地址。
regEx.Pattern ="^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,4}$"
1)有人请用文字说明这种模式是如何工作的吗?背后的破折号( - )是什么?喜欢w-,Z -
^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,4}$
2)此外,如果顶级域名为2到3个字符(如.com,.edu),它看起来只返回TRUE。如何在点(。)后更改为无限制的顶级域名?例如:test1@domain1.career,test2 @ domain2.consulting
先谢谢你,
答案 0 :(得分:0)
^ = String starts with
\w = Ranges: matches a letter between A to B,a to b and figures from 1 to 9
\. = matches character (.)
{1,} = Occur one or more times
\@ = matches character (@)
[\da-zA-Z-] = match a single character between digit 0-9,a-z , A-Z and -
{2,4} = Occur 2 to 4 times
^[\w-\.]{1,} indicate abc9-. or 9ab-.
[\da-zA-Z-]{2,4} indicates 1ab or ab- or ab3-
to change unlimited top-level domain after the dot (.) change Regular Expression
^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{1,}$
output will be: test1@domain1.career