[英]JSF <f:validateRegex pattern
I cant understand this: 我不明白这一点:
<f:validateRegex pattern="((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}" />
please someone explain for me 请有人为我解释
((\\(\\d{3}\\) ?)|(\\d{3}-))?\\d{3}-\\d{4}
is a regex for a US phone number, either in the form: ((\\(\\d{3}\\) ?)|(\\d{3}-))?\\d{3}-\\d{4}
是美国电话号码的正则表达式,格式为:
555-555-5555
or(555)555-5555
or555-5555
555-555-5555
或(555)555-5555
或555-5555
First of all \\d
means digit. 首先
\\d
表示数字。
This part ((\\(\\d{3}\\) ?)|(\\d{3}-))?
这部分
((\\(\\d{3}\\) ?)|(\\d{3}-))?
means (555)
or 555-
, once or none at all. 表示
(555)
或555-
,一次或根本没有。 Broken down its 细分其
( (\(\d{3}\) ?) | (\d{3}-) ) ?
( (3 digits with () ?- once or no) |-OR (three digits plus - ) ) ?-once or none
This part \\d{3}-
means 555-
(three digits plus -). \\d{3}-
这部分表示555-
(三位数加-)。
This part \\d{4}
means 5555
(four digits). \\d{4}
这部分的意思是5555
(四位数)。
BTW, the 5
's are just placeholders for any digit . 顺便说一句,
5
只是任何数字的占位符。
The <f:validateRegex pattern
tag and attribute is to validate an input field to match one of the above three patterns. <f:validateRegex pattern
标记和属性用于验证输入字段以匹配上述三种模式之一。
See more at Regualar Expressions 在Regualar Expressions中查看更多
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.