The regular expression Daquan

Source: Internet
Author: User

First, the expression of verifying numbers

Number: ^[0-9]*$
N digits: ^\d{n}$
at least n digits: ^\d{n,}$
m-n digits: ^\d{m,n}$
0 and non 0 digits: ^ (0|[ 1-9][0-9]*) $
A number with a maximum of two decimal places that starts with a non 0: ^ ([1-9][0-9]*) + (. [ 0-9]{1,2})? $
Positive or negative numbers with 1-2 decimal places: ^ (\-)? \d+ (\.\d{1,2})? $
Positive, negative, and decimal: ^ (\-|\+)? \d+ (\.\d+)? $
has a positive real number of two decimal places: ^[0-9]+ (. [ 0-9]{2})? $
has a positive real number of decimal places: ^[0-9]+ (. [ 0-9]{1,3})? $
Non-zero positive integer: ^[1-9]\d*$ or ^ ([1-9][0-9]*) {1,3}$ or ^\+?[ 1-9][0-9]*$
Nonzero negative integer: ^\-[1-9][]0-9″*$ or ^-[1-9]\d*$
non-negative integer: ^\d+$ or ^[1-9]\d*|0$
non-positive integer: ^-[1-9]\d*|0$ or ^ ((-\d+) | ( 0+) $
Non-negative floating-point number: ^\d+ (\.\d+)? $ or ^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$
non-positive floating-point number: ^ ((-\d+ (\.\d+)?) | (0+ (\.0+)?)) $ or ^ (-([1-9]\d*\.\d*|0\.\d*[1-9]\d*)) |0?\.0+|0$
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]*)) $
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]*))) $
Floating-point number: ^ (-?\d+) (\.\d+)? $ or ^-? ([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0) $
Two, an expression that verifies the character

Kanji: ^[\u4e00-\u9fa5]{0,}$
English and numeric: ^[a-za-z0-9]+$ or ^[a-za-z0-9]{4,40}$
All characters of length 3-20: ^.{ 3,20}$
A string of 26 English letters: ^[a-za-z]+$
A string of 26 uppercase English letters: ^[a-z]+$
A string of 26 lowercase English letters: ^[a-z]+$
A string consisting of a number and 26 English letters: ^[a-za-z0-9]+$
A string of numbers, 26 letters, or underscores: ^\w+$ or ^\w{3,20}$
Chinese, English, and numerals include underscores: ^[\u4e00-\ u9fa5a-za-z0-9_]+$
Chinese, English, numeric but not underlined symbols: ^[\u4e00-\u9fa5a-za-z0-9]+$ or ^[\u4e00-\u9fa5a-za-z0-9]{2,20}$
You can enter a character:[^%& ' that contains ^%& ',; =?$\ ', =?$\x22]+
prohibit input of characters containing ~: [^~\x22]+
Iii. Special needs expression

Email Address: ^\w+ ([-+.] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) *$
Domain name: [a-za-z0-9][-a-za-z0-9]{0,62} (/.[ A-ZA-Z0-9][-A-ZA-Z0-9]{0,62}) +/.?
interneturl:[a-za-z]+://[^\s]* or ^http://([\w-]+\.) +[\w-]+ (/[\w-./?%&=]*)? $
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}$
Phone numbers ("Xxx-xxxxxxx", "xxxx-xxxxxxxx", "xxx-xxxxxxx", "xxx-xxxxxxxx", "XXXXXXX", and "XXXXXXXX"): ^ ($$\d{3,4}-) |\d{3.4}-)? d{7,8}$
Domestic phone number (0511-4405222, 021-87888822): \d{3}-\d{8}|\d{4}-\d{7}
Social Security Number (15-bit, 18-digit number): ^\d{15}|\d{18}$
Short ID number (number, letter X end): ^ ([0-9]) {7,18} (x| X)? $ or ^\d{8,18}| [0-9x] {8,18}| [0-9x] {8,18}?$
Whether the account is legal (the letter starts with 5-16 bytes allowed, alphanumeric underline): ^[a-za-z][a-za-z0-9_]{4,15}$
Password (beginning with letter, length between 6~18, can only contain letters, numbers, and underscores): ^[a-za-z]\w{5,17}$
Strong password (must contain a combination of uppercase and lowercase letters and numbers, cannot use special characters, length between 8-10): ^ (? =.*\d) (? =.*[a-z]) (? =.*[a-z]). {8,10}$
Date format: ^\d{4}-\d{1,2}-\d{1,2}
12 months of the year (01~09 and 1~12): ^ (0?[ 1-9]|1[0-2]) $
One months of 31 days (01~09 and 1~31): ^ (0?[ 1-9]) | ((1|2) [0-9]) |30|31) $

The 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.