RegularExpressionValidator

zhaozj2021-02-16  56

-, "^" head match ^ Front Indicates a string that starts with "Front". Second, the "$" tail match TAIL $ indicates the string ending with "tail". Third, all escape sequences all the escape sequences are "/" head. Such as "^", "$", " ", "(") "has special significance in the expression, so in the regular expression" / ^ "," / $ "," / ","/(","/)"To represent. Fourth, the character cluster [AZ] matches lowercase characters; [AZ] matching the writing character; [A-ZA-Z] matches all characters; [0-9] matches all numbers; [/./-/ ] Match all the sentences, Dimensional and plus sign; [^ AZ] In addition to a character other than lowercase letters; ^ [^ AZ] The first character cannot be lowercase letters; [^ 0-9] In addition to all characters outside the number; five, repetition ^ A {4} $ represents AAAA; ^ a {2, 4} represents AA, AAA or AAAA; ^ a {2,} represents more than two A strings;. {2} represents all two characters;

Next, two common examples are given:

1. Email's verification requirements: (1) must include a string behind "@" contains at least one "." (3) "@" front and back strings by one or one The above letters, numbers, underscores or minus, according to these rules, the following regular expressions can be related to the following regular expressions: ^ [A-ZA-Z0-9 _ / -] {1,} @ [A-ZA-Z0-9_ / -] {1,} /. [A-ZA-Z0-9 _ / -.] {1,} $ or: /W ([- .]/w ) *@ / w ([-.]/w ) * /. / w ([-.] / w ) *

2, the verification requirements of the phone number: (1) Phone number is numbered, "(", ")" and "-" Composition (2) The phone number is 3 to 8 bits (3) If the phone number contains a zone number, then Area number (",") "or" - "and other parts (5) The mobile phone number is 11 or 12 bits, if it is 12 bits, then the first bit is 0 (6) 11-bit mobile phone number, the first bit and the second bit of "13" (7) 12-bit mobile phone number, the third bit is "13" according to these rules, can be The following regular expressions: (^ [0-9] {3, 4} / - [0-9] {3,8} $) | (^ [0-9] {3,8} $) | (^ / ([0-9] {3,4} /) [0-9] {3,8} $) | (^ 0 {0, 1} 13 [0-9] {9} $)

转载请注明原文地址:https://www.9cbs.com/read-17901.html

New Post(0)