解释验证模式 [英] Explain Pattern for Validation

查看:94
本文介绍了解释验证模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

海,

我们使用以下模式对电子邮件,Web,数字,字符进行验证,

Hai,

We are used Validate for Email, Web, numbers, characters using pattern like following,

^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$



我也用,但我听不懂.模式的语法说明了什么.
请说明...



I also using, but I can''t understand it. What is the syntax of pattern, explained it.
Please explain...

推荐答案



我也用,但我听不懂.模式的语法是什么?
请解释...



I also using, but I can''t understand it. What is the syntax of pattern, explained it.
Please explain...


检查文章以获得更好的Regiular表达式解释,
http://www.regular-expressions.info/reference.html [
Check the article to get better explanation of Regiular expression,
http://www.regular-expressions.info/reference.html[^]


^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}






/ = Begin an expression
^ = The matched string must begin here, and only begin here
\w = any word (letters, digits, underscores)
+ = match previous expression at least once, unlimited number of times
[] = match any character inside the brackets, but only match one
\+\. = match a literal + or .
\w = another word
- = match a literal -
* = match the previous expression zero or infinite times
@ = match a literal @ symbol
() = make everything inside the parentheses a group (and make them referencable)
[] = another character set
\w- = match any word or a literal -
+ = another 1 to infinity quantifier
\. = match another literal .
* = another 0 to infinity quantifier
\w+ = match a word at least once
[\w-]*\. = match a word or a dash at least zero times, followed by a literal .
() = another group
[a-z]{2,4} = match lowercase letters at least 2 times but no more than 4 times
| = "or" (does not match pipe)
\d+ = match at least 1 digit


这篇关于解释验证模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆