Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用以下模式"^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"来验证电子邮件地址。
"^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"
我想在这里添加额外的功能。即“至少 2 个字母数字字符应介于 @ 和 . 之间。”
请建议我解决方案。
不是很难做到:
^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" + "[A-Za-z0-9-]{2,}(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$
我唯一改变的是+for a {2,}。+表示1个以上,表示{2,}2个以上。
+
{2,}