我Asp.Net/C#
在我的项目中使用。在我Regular Expression Validator
用来验证电子邮件地址的一个表单中。我搜索了一些验证电子邮件的示例。我发现了这个\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
可以任何人解释我这个模式,这将非常有帮助。任何解释都非常感谢。
谢谢。
我Asp.Net/C#
在我的项目中使用。在我Regular Expression Validator
用来验证电子邮件地址的一个表单中。我搜索了一些验证电子邮件的示例。我发现了这个\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
可以任何人解释我这个模式,这将非常有帮助。任何解释都非常感谢。
谢谢。
一些简短的提示:
\w 代表单词字符
[-+.'] 表示大括号中的字符之一
plus 和 * 是量词
( ) 包围一个可以创建反向引用的组(您可以以编程方式引用或读取的内容)
更长的(自动)解释:
\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
Match a single character that is a “word character” (letters, digits, and underscores) «\w+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Match the regular expression below and capture its match into backreference number 1 «([-+.']\w+)*»
Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
Note: You repeated the capturing group itself. The group will capture only the last iteration. Put a capturing group around the repeated group to capture all iterations. «*»
Match a single character present in the list “-+.'” «[-+.']»
Match a single character that is a “word character” (letters, digits, and underscores) «\w+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Match the character “@” literally «@»
Match a single character that is a “word character” (letters, digits, and underscores) «\w+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Match the regular expression below and capture its match into backreference number 2 «([-.]\w+)*»
Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
Note: You repeated the capturing group itself. The group will capture only the last iteration. Put a capturing group around the repeated group to capture all iterations. «*»
Match a single character present in the list “-.” «[-.]»
Match a single character that is a “word character” (letters, digits, and underscores) «\w+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Match the character “.” literally «\.»
Match a single character that is a “word character” (letters, digits, and underscores) «\w+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Match the regular expression below and capture its match into backreference number 3 «([-.]\w+)*»
Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
Note: You repeated the capturing group itself. The group will capture only the last iteration. Put a capturing group around the repeated group to capture all iterations. «*»
Match a single character present in the list “-.” «[-.]»
Match a single character that is a “word character” (letters, digits, and underscores) «\w+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
我使用 RegexBuddy 创建了更长的自动解释
编辑:
要获得有关正则表达式的一些入门信息,您可以查看http://www.regular-expressions.info/