正则表达式 - 验证 Gmail 地址 [英] Regular Expression - Validate Gmail addresses
本文介绍了正则表达式 - 验证 Gmail 地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建一个表达式来验证 Gmail 地址.这就是我迄今为止所做的.
I am trying to create an expression to validate Gmail addresses. That's what I've done so far.
^([\w]*[\w\.]*(?!\.)@gmail.com)
我正在尝试创建一个表达式来验证 Gmail 地址.这就是我迄今为止所做的.
I am trying to create an expression to validate Gmail addresses. That's what I've done so far.
但它不能如我所愿.
Gmail 地址:
- 第一个和最后一个字符必须是 [a-z0-9]
- 用户名仅包含内容 [a-z0-9.]
- 不能有连续的句点(即:
e..o@gmail.com
[这是错误的]) - 用户名的长度必须在 6 到 30 个字母之间.
老实说,我对正则表达式没有太多经验.
Being honest I don't have much experience with the Regular Expressions.
顺便问一下,有正则表达式的文档吗?
By the way, is there a documentation for Regular Expression?
推荐答案
您没有说明您使用的是哪个正则表达式实现.
You did not tell which regex implementation you use.
^[a-z0-9](\.?[a-z0-9]){5,}@g(oogle)?mail\.com$
[a-z0-9]
第一个字符(\.?[a-z0-9]){5,}
至少五个以下字母数字字符,前面可能有一个点(参见@Daniel 的评论,从@Christopher 的回答中复制)g(oogle)?mail
gmail 或 googlemail(参见@alroc 的回答)[a-z0-9]
first character(\.?[a-z0-9]){5,}
at least five following alphanumeric characters, maybe preceded by a dot (see @Daniel's comment, copied from @Christopher's answer)g(oogle)?mail
gmail or googlemail (see @alroc's answer)
可能您也想使用不区分大小写的模式匹配.(/.../i
在 JavaScript 中.)
Probably you will want to use case-insensitive pattern matching, too. (/.../i
in JavaScript.)
这篇关于正则表达式 - 验证 Gmail 地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文