(turn) Regular expression Daquan

Source: Internet
Author: User

First, the numeric check expression

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

2. Number of n digits: ^d{n}$

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

4. Number of m-n digits: ^d{m,n}$

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

6. A number with a maximum of two decimal places not starting with 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. A positive integer other than 0: ^[1-9]d*$ or ^ ([1-9][0-9]*) {1,3}$ or ^+? [1-9] [0-9]*$

12. Negative integer not 0: ^-[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) $

Second, character check expression

1. Kanji: ^[u4e00-u9fa5]{0,}$

2. English and numerals: ^[a-za-z0-9]+$ or ^[a-za-z0-9]{4,40}$

3. All characters with a length of 3-20: ^. {3,20}$

4. A string consisting of 26 English letters: ^[a-za-z]+$

5. A string consisting of 26 lowercase/uppercase English letters: ^[a-z]+$ ^[a-z]+$

6. A string consisting of a number and 26 English letters: ^[a-za-z0-9]+$

7. A string consisting of numbers, 26 letters, or underscores: ^w+$ or ^w{3,20}$

8. Chinese, English, numerals include underline: ^[u4e00-u9fa5a-za-z0-9_]+$

9. Chinese, English, numerals but not including underline symbols: ^[u4e00-u9fa5a-za-z0-9]+$ or ^[u4e00-u9fa5a-za-z0-9]{2,20}$

10. Can input containing can input containing ^%& ',; =?$ "and other characters:[^%& ',; =? $x 22]+

11. Prohibit input of characters containing ~: [^~x22]+

Iii. Expression of special needs

1. Email Address: ^w+ ([-+.] w+) *@w+ ([-.] w+) *.w+ ([-.] w+) *$

2. Domain name: [a-za-z0-9][-a-za-z0-9]{0,62} (/.[ A-ZA-Z0-9][-A-ZA-Z0-9]{0,62}) +/.?

3. InternetURL: [a-za-z]+://[^s]* or ^http://([w-]+.) +[w-]+ (/[w-./?%&=]*)? $

4. Mobile Number: ^ (13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8| 9]|18[0|1|2|3|5|6|7|8| 9]) d{8}$

5. Telephone numbers ("Xxx-xxxxxxx", "xxxx-xxxxxxxx", "xxx-xxxxxxx", "xxx-xxxxxxxx", "XXXXXXX", and "XXXXXXXX"): ^ ((d{3,4}-) |d{3.4}-)? d{ 7,8}$

6. Domestic phone number: D{3}-d{8}|d{4}-d{7}

7. ID Number: ^d{15}|d{18}$


Article excerpt from:http://www.kuqin.com/shuoit/20151215/349463.html

(turn) Regular expression Daquan

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.