# An expression that verifies a number

Source: Internet
Author: User

1 Number: ^[0-9]*\$

2 N-bit number: ^\d{n}\$

3 Number of at least n digits: ^\d{n,}\$

4 m-n digits: ^\d{m,n}\$

Numbers starting with 50 and non 0: ^ (0|[ 1-9][0-9]*) \$

6 numbers with a maximum of two decimal places starting with non 0: ^ ([1-9][0-9]*) + (. [ 0-9]{1,2})? \$

7 positive or negative numbers with 1-2 decimal places: ^ (-)? \d+ (. \d{1,2})? \$

8 positive, negative, and fractional: ^ (-|+)? \d+ (. \d+)? \$

9 positive real numbers with two decimal places: ^[0-9]+ (. [ 0-9]{2})? \$

10 positive real numbers with a decimal position: ^[0-9]+ (. [ 0-9]{1,3})? \$

11 non-zero positive integers: ^[1-9]\d\$ or ^ ([1-9][0-9]) {1,3}\$ or ^+? [1-9] [0-9]*\$

12 non-zero negative integer: ^-[1-9][]0-9 "\$ or ^-[1-9]\d\$

13 non-negative integers: ^\d+\$ or ^[1-9]\d*|0\$

14 Non-positive integers: ^-[1-9]\d*|0\$ or ^ ((-\d+) | ( 0+)) \$

15 non-negative floating point number: ^\d+ (. \d+)? \$ or ^[1-9]\d.\d|0.\d[1-9]\d|0?. 0+|0\$

16 Non-positive floating-point number: ^ ((-\d+ (. \d+)?) | (0+ (. 0+)?)) \$ or ^ (-([1-9]\d.\d|0.\d[1-9]\d)) | 0+|0\$

17 Positive floating point number: ^[1-9]\d.\d|0.\d[1-9]\d\$ or ^ ([0-9]+.[ 0-9][1-9][0-9]) | ([0-9][1-9][0-9]. [0-9]+) | ([0-9][1-9][0-9])) \$

18 Negative floating point number: ^-([1-9]\d.\d|0.\d[1-9]\d) \$ or ^ (-([0-9]+.[ 0-9][1-9][0-9]) | ([0-9][1-9][0-9]. [0-9]+) | ([0-9][1-9][0-9]))) \$

19 floating-point number: ^ (-?\d+) (. \d+)? \$ or ^-? ([1-9]\d.\d|0.\d[1-9]\d|0?. 0+|0) \$

An expression that verifies a number

Related Keywords:

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.