这应该在@符号前不需要两个或多个字符。
^[a-zA-Z][a-zA-Z0-9]*(?:\.+[a-zA-Z0-9]+)*@domain\.com$
下面是它的分解:
^ Make sure we start at the beginning of the string
[a-zA-Z] First character needs to be a letter
[a-zA-Z0-9]* ...possibly followed by any number of letters or numbers.
(?: Start a non-capturing group
\.+ Match any periods...
[a-zA-Z0-9]+ ...followed by at least one letter or number
)* The whole group can appear zero or more times, to
offset the + quantifiers inside. Otherwise the
period would be required
@domain\.com$ Match the rest of the string. At this point, the
only periods we've allowed are followed by at
least one number or letter
@ dan08不是,如果是方括号 - 那么它就失去了特殊的意义。 – vlaz
真实!不知道。评论撤销。 – dan08
@ dan08耶 - 大多数人物在方括号中失去了他们的特殊含义。最显着的不是'[]'(你仍然需要逃避那些),以及表示字符范围的'-'。但是,如果放置在开始或结束时,则将其视为破折号。 – vlaz