[] In the string "[0-9] {15}" above is used to define optional characters, and {} is used to define the number of characters.
Besides [? -?] In addition to the definition, you can directly write acceptable characters. For example, [wjt98] indicates that
The control towel can only contain the "W", "J", "T", "9", and "8" characters.
In [], you can also use "^" to define the anti-set. For example, [^ A-SJ indicates other characters except "a"-"S ".
Both are acceptable.
{} Is used to define the number of characters. We have used a definition method above. In fact, {} has the following 5
Common formats:
The format {3} has already been used. It indicates that only three characters can be accepted, neither more nor less.
The format of {} indicates that 2-5 characters can be entered. For example, [0-9] {} indicates that 2 and 5 characters can be entered.
.
{N,} indicates that N to infinite characters can be accepted. For example, [A-Za-z {3,} indicates that at least three English characters must be entered in this column.
Characters.
The above describes the basic usage of the regularexpression attribute, but it cannot meet the requirements. If you want a table
If the value reaches any character, it cannot be expressed in []. In repularexpression, the character that expresses any character is "."
For example,. {1,} indicates that the string can be 1 to an infinite number of arbitrary characters.
Sometimes you need to use multiple-choice when using string expression rules, for example, either all are English characters,
Either it is a number, then we can use the "|" symbol, which is equivalent to the OR operator. For example, the [A-Za-Z] | [0-9] {3} table
If "|" appears in regularexpression, you can express it to avoid confusion in reading.
Formula is included in.
The above "[]", ".", "{}", "()", and "|" are all special symbols of regularexpression.
The accepted characters must be preceded by "\"
Comprehensive application of regularexpression
(1) Verify the email bar
{1 ,}@. {1 ,}\ .. {1 ,}
(2) Verify the telephone bar
(\ ([0-9] {0, 4} \) [0-9] {3, 15}) | ([0-9] (3, L 5) -[O-9] {}) | ([0-9] {11 })
(3) Verify the address bar
. {1 ,}( city | town | township). {1 ,}( road | street | road). {1 ,}. {0 .}