Regular Expression in the regularexpressionvalidator Control

Source: Internet
Author: User
Regularexpressionvalidat Or control regular expression usage

Verification Number:

Only one number can be entered

Expression ^ \ D $
Description Match a number
Matching example 0, 1, 2, 3
Example of Mismatch

Only n numbers can be entered

Expression ^ \ D {n} $ for example ^ \ D {8} $
Description Match 8 numbers
Matching example 12345678,22223334, 12344321
Example of Mismatch

 

You can enter at least N numbers.

Expression ^ \ D {n ,}$ for example ^ \ D {8,} $
Description Match at least N numbers
Matching example 12345678,123456789, 12344321
Example of Mismatch

 

Only M to N numbers can be entered

Expression ^ \ D {m, n} $ for example ^ \ D {7, 8} $
Description Match m to N numbers
Matching example 12345678,1234567
Example of Mismatch 123456,123456789

 

Only numbers can be entered

Expression ^ [0-9] * $
Description Match any number
Matching example 12345678,1234567
Example of Mismatch E, clear moon, http://blog.csdn.net/21aspnet

 

Only numbers in a certain range can be entered.

Expression ^ [12-15] $
Description Number matching a certain range
Matching example 12,13, 14,15
Example of Mismatch

 

Only numbers with 0 and non-0 headers can be entered.

Expression ^ (0 | [1-9] [0-9] *) $
Description It can be 0, the first number cannot be 0, and the number can be 0
Matching example 101,100
Example of Mismatch 01, clear moon, http://blog.csdn.net/21aspnet

 

Only real numbers can be input.

Expression ^ [-+]? \ D + (\. \ D + )? $
Description Matching real number
Matching example 18, + 3.14,-9.90
Example of Mismatch . 6, 33 S, 67-99

 

Only the positive number of N decimal places can be entered

Expression ^ [0-9] + (. [0-9] {n })? $ With ^ [0-9] + (. [0-9] {2 })? $ Example
Description Matches the positive number of N decimal places
Matching example 2.22
Example of Mismatch 2.222,-2.22, http://blog.csdn.net/21aspnet

 

Only the positive number of M-N decimal places can be entered

Expression ^ [0-9] + (. [0-9] {m, n })? $ With ^ [0-9] + (. [0-9] {1, 2 })? $ Example
Description Matches the positive number of M to N decimal places
Matching example 2.22, 2.2
Example of Mismatch 2.222,-2.2222, http://blog.csdn.net/21aspnet

 

Only positive integers other than 0 can be entered.

Expression ^ \ +? [1-9] [0-9] * $
Description Match a positive integer other than 0
Matching example 234
Example of Mismatch 0,-4,

 

Only negative integers other than 0 can be entered.

Expression ^ \-[1-9] [0-9] * $
Description Match a non-zero negative integer
Matching example -2,-23,-234
Example of Mismatch 0, 4,

 

Only n characters can be entered

Expression ^. {N} $ take ^. {4} $ as an Example
Description Match n characters. Note that only one Chinese character is counted.
Matching example 1234, 12we, 123 Clear, clear moon
Example of Mismatch 0,123,123 WWW, http://blog.csdn.net/21aspnet/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.