First, the check digit of expression
Digital: ^ [0-9] * $
The number n of bits: ^ d {n} $
At least an n-bit number: ^ d {n,} $
Mn-bit numbers: ^ d {m, n} $
Digital zero and non-zero at the beginning: ^ (0 | [1-9] [0-9] *) $
Beginning with zero up to two decimal places: (. [0-9] {1,2})? ^ ([1-9] [0-9] *) $ +
1-2 decimal number with a positive or negative:? ^ (-) d + (. D {1,2}) $
Positive, negative, and decimals:?? ^ (- | +) d + (. D +) $
Two positive real number of decimal places: (. [0-9] {2})? ^ [0-9] + $
1 to 3 a positive real number of decimal places: (. [0-9] {1,3})? ^ [0-9] + $
Nonzero positive integer: ^ [1-9] d * $ or ^ ([1-9] [0-9] *), or {1,3} ^ $ + [1-9] [0-9]? * $
Negative integer zero: ^ - [1-9] [] 0-9 "or * ^ $ - [1-9] * $ D
Non-negative integers: ^ d + $ or ^ [1-9] d * | 0 $
Non-positive integer: ^ - [1-9] d * | 0 $ or ^ ((- d +) | (0 +)) $
? Non-negative floating-point numbers: ^ d + (. D +) $ or ^ [1-9] d * .d * | 0.d * [1-9] d * | 0 .0+ | 0 $?
Non-positive float: (.?.? (- d + (d +)) | (0 + (0 +))) ^ $ or ^ (- ([1-9] d * .d * | 0.d * [ 1-9] d *)) | 0 .0+ |? 0 $
Positive float:. ^ [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 float: ^ - ([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] *))) $
Float: ^ (- d +?) $ Or ^ - ([1-9] d * .d * | 0.d * [1-9] d * | 0 .0+ | 0 (d +.)??? ) $
Second, check character expression
Characters: ^ [a - 龥] {0,} $
Alphanumeric: ^ [A-Za-z0-9] + $ or ^ [A-Za-z0-9] {4,40} $
All characters in length is 3-20: {^} $ 3,20.
A string consisting of letters 26: ^ [A-Za-z] + $
String 26 from the English capital letters: ^ [AZ] + $
String consists of 26 lowercase English letters: ^ [az] + $
String of digits and letters of the English 26: ^ [A-Za-z0-9] + $
String of digits, letters or underscore 26 consisting of: ^ w + $ or ^ w {3,20} $
Chinese, English, numbers underlined comprising: ^ [a - 龥 A-Za-z0-9 _] + $
Chinese, English, numbers, symbols such as but not underlined: ^ [a - 龥 A-Za-z0-9] + $ ^ or [a - 龥 A-Za-z0-9] {2,20} $
- disable input characters comprising: [~ ^ "] +
Third, the special needs of expression
Email地址:^w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$
域名: [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]* 或 ^http://([w-]+.)+[w-]+(/[w-./?%&=]*)?$
Phone 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} $
Domestic telephone number (0511-4405222,021-87888822): d {3} -d {8} | d {4} -d {7}
Phone number regular expression (support phone number, area code 3-4, 7-8 live numbers 1-4 digit extension number): ((d {11}) | ^ ((d {7,8}) | (d {4} | d {3}) - (d {7,8}) | (d {4} | d {3}) - (d {7,8}) - (d {4} | d { 3} | d {2} | d {1}) | (d {7,8}) - (d {4} | d {3} | d {2} | d {1})) $)
ID number (15, 18 digits), the last digit is a check digit, or may be a digital character X: (^ d {15} $) | (^ d {18} $) | (^ d {17 } (d | X | x) $)
Account is valid (beginning with the letter, allowing 5-16 bytes to allow alphanumeric underlined): ^ [a-zA-Z] [a-zA-Z0-9 _] {4,15} $
Password (start with a letter, a length between 6 and 18, can contain letters, numbers and underscores): ^ [a-zA-Z] w {5,17} $
Strong passwords (which must contain a combination of uppercase and lowercase letters and numbers, special characters can not be used, a length of between 8-10): ^ (?. = * D) (= * [(= * [az]?.)?. AZ]) [a-zA-Z0-9] {8,10} $
Strong passwords (which must contain a combination of uppercase and lowercase letters and numbers, special characters may be used, a length of between 8-10): ^ (?. = * D) (= * [(= * [az]?.)?. AZ]). {8,10} $
Date format: ^ d {4} -d {1,2} -d {1,2}
A year of 12 months (01 ~ 09 and 1 ~ 12): ^ (0 [1-9] | 1 [0-2]?) $
Month of 31 days (01 ~ 09 and 1 ~ 31): ^ ((0 [1-9]) | ((1 | 2) [0-9]) | 30 | 31?) $
xml Bunken: (? [a-zA-Z] + -). ^ + [a-zA-Z0-9] + \ [x | X] [m | M] [l | L] $
Chinese characters in regular expressions: [a - 龥]
Blank line regular expression: s * (can be used to delete blank lines)
HTML markup regular expression: <(S *?) [^>] *> * | <* /> (Inclusive blank character regular expression:.?.? ^ S * | s * $ or (^ s * ) | (s * $) (it can be used to remove white space character of the line end of the line (including spaces, tabs, page breaks, etc.), very useful expression)
Tencent QQ: [1-9] [0-9] {4,} (Tencent QQ number 10000 from the start)
China Postal Code: [1-9] d {5} (?! d) (6-digit ZIP code for China)
IP Address: (? (:( ?: 25 [0-5] | 2 [0-4] \ d | [01] \ d \ d) \??.) {3} (?: 25 [0-5 ] | 2 [0-4] \ d |? [01] \ d \ d))?
No micro-channel public attention and headlines today, excellent article continued update. . . . .