One, the expression of the check number
- The Numbers: ^ [0-9] * $
- N digits: ^\d{n}$
- At least n digits: ^\d{n,}$
- M -n digits: ^\d{m,n}$
- The number of zero and non-zero start: ^ (0 | [1-9] [0-9] *) $
- Non-zero digits with at most two decimal digits: ^([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+)? $
- Positive real numbers with two decimal places: ^[0-9]+(.[0-9]{2})? $
- Positive real numbers with 1 to 3 decimal places: ^[0-9]+(.[0-9]{1,3})? $
- Non-zero positive integers: ^ \ d * (1-9] or [[1-9] [0-9] ∗) 1, 3, or ^ (1-9 [] [0-9] *) {1, 3} or ((1-9] [0-9] ∗) 1, 3, or ^ +? [1-9] [0-9] * $
- Nonzero negative integer: ^ – 1-9 [] [] 0-9 “* or – [1-9] \ d ∗ or ^ – [1-9] \ d * or – [1-9] \ d ∗
- Nonnegative integers: ^ or [1-9] \ \ d + d ∗ ∣ ^ 0 or 1-9] [\ | 0 or d * (1-9] \ d ∗ ∣ 0
- A positive integer: ^ – [1-9] \ | 0 or d * ((- \ d +) ∣ (0 +)) or ^ ((\ d +) | (0 +)) or ((- \ d +) ∣ (0 +))
- Non-negative floating point: ^\d+(.\d+)? Or ^ [1-9] \ d * \ \ d * \ | 0. [1-9] \ d \ d * * | 0? \. | 0 + 0
- Non-positive float: ^((-\d+(.\d+)?) | ((. 0 0 + +)?) ) or ^ (- (1-9] [\ d * \ \ d * \ | 0. [1-9] \ d \ d * *)) | 0? \. | 0 + 0
- Are floating point Numbers: ^ 1-9] [\ d * \ | 0. D * (1-9] \ d \ 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 Numbers: ^ – (1-9] [\ d * \ | 0. D * (1-9] \ d \ 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: ^(-? \d+)(.\d+)? Or ^ -? ([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0? \. | 0 + 0)
Second, the expression of the verification character
- Chinese characters: ^ [\ u4e00 – \ u9fa5] {0} $
- English and Numbers: ^ + [A – Za – z0-9] or [A – Za – z0-9] 40 or ^ 4 [A Za – z0-9] 40 {4} or [A – Za – z0-9] 4, 40
- All characters from 3 to 20: ^.{3,20}$
- The value is A string of 26 letters: ^[a-za-z]+$
- The value contains 26 uppercase letters: ^[a-z]+$
- The value is a string of 26 lowercase letters: ^[a-z]+$
- The value is A string of 26 letters and digits: ^[A-za-z0-9]+$
- A string of numbers, 26 letters, or underscores: ^\w+ or \w3,20 or ^\w{3,20} or \w3,20
- Chinese, English, digits including underscore: ^[\u4E00-\ U9FA5A-zA-z0-9_]+$
- Chinese, English, numerals but not underscores: ^[\ u4e00-\ u9fa5a-za-z0-9]+ or ^[\ u4e00-\ u9fa5a-za-z0-9]{2,20}
- Can be entered with ^%&’,; =? \” and other characters: [^%&’,;=?\x22]+
- Forbid input containing
The character is [^\x22]+
Special requirements expression
- Email Address: ^\w+([-+.]\w+)@\w+([-.]\w+).\w+([-.]\w+)*$
- Domain name: [a – zA – Z0-9] [9] – a – zA – Z0 – on conversion {0} (. [a zA – Z0-9] [9] – a – zA – Z0 – on conversion {0}) +.?
- InternetURL: [a zA – z] + : / / [^ \ s] * or ^ http:// ([-] \ w +.) +[\w-]+(/[\w-./?%&=]*)? $
- Mobile phone number: ^ (13 [0-9] | | 5 | [7] 14 15 [0 | 1 | 2 | 3 | 4 5 6 7 | | | | | 8 9] | 18 [0 | 1 | 2 | 3 | 5 6 7 8 | | | | 9]) \ d {8} $
- Phone number (” XXX – XXXXXXX “, “XXXX – XXXXXXXX”, “XXX – XXXXXXX”, “XXX – XXXXXXXX”, “XXXXXXX” and “XXXXXXXX) : ^ ((\ d {3, 4} -) | \ d {} 3.4 -)? \ d {7, 8} $
- Home phone number (0511-4405222, 021-87888822) : \ d {3} – \ d {8} | \ d {4} – \ d {7}
- Regular expression for phone numbers (supporting mobile numbers, 3-4 area codes, 7-8 live numbers, and 1-4 extension numbers) : ((\ 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, and digital), and the last is the check digit, may for digital or character: (X ^ \ d {15}) ∣ (\ d18) | (^ \ d {and}) ∣ (\ d18) | (^ \ d {and} (\ d | | X) X $)
- Account is (legal letter, allow 5-16 bytes, allow alphanumeric underlined) : ^ [a zA – Z] [a zA – Z0-9 _] {4, 15} $
- Password (must start with a letter and contain only letters, digits, and underscores (_).) : ^[a-za-z]\w{5,17}$
- Strong password (must contain uppercase and lowercase letters and digits, cannot use special characters, and is between 8 and 10 characters in length) : ^(? =.\d)(? =.[a-z])(? =. * [a-z]) [A zA – Z0-9] {8, 10} $
- Strong passwords (must contain a combination of uppercase and lowercase letters and numbers, special characters can be used, and are between 8 and 10 characters in length) : ^(? =.\d)(? =.[a-z])(? =. * [a-z]). 8, 10 {} $
- Date format: ^\d{4}-\d{1,2}-\d{1,2}
- The twelve months of the year (01 ~ 09 and 1 ~ 12) : ^(0? [1-9] [2-0]) $| 1
- 31 days of a month (01 ~ 09 and 1 ~ 31) : ^((0? [1-9]) | | 2 (1) ([0-9]) | | 31) $30
- Input format of money:
- There are four forms of money we can accept :”10000.00″ and “10,000.00”, and “10000” and “10,000” without “cent” : ^[1-9][0-9]*$
- This means that any one does not begin with 0, but it also means that a character “0” is not through, so we use the form below: ^ (0 | [1-9] [0-9] *) $
- A 0 or a number that doesn’t start with 0. We can also allow the beginning there is a minus sign: ^ (0 | -? [1-9] [0-9] *) $
- This represents a 0 or a number that might be negative and doesn’t start with a 0. Let the user start with 0. Let’s get rid of the minus, because money can’t be negative. ^[0-9]+(.[0-9]+)? $
- Must be clear, decimal point should be at least 1 digit, so it is not through “10.”, but “10” and “10.2” is through: ^ [0-9] + (. [0-9] {2})? $
- So we provisions of decimal point must be two, if you think that is too harsh, it can be: ^ [0-9] + (. [0-9] {1, 2})? $
- This allows the user to write only one decimal place. Below we should consider a comma in the digital, we can be like this: ^ [0-9] {1, 3} ([0-9] {3}), * (. [0-9] {1, 2})? $
- 1 to 3 Numbers, followed by any comma + 3 Numbers, commas become optional, rather than having to: ^ ([0-9] + | [0-9] {1, 3} ([0-9] {3}), * (. [0-9] {1, 2})? $
- Note: This is the final result, remember that “+” can be replaced with “*” if you think empty strings are acceptable (strange, why?). And finally, don’t forget to get rid of that backslash when you’re using a function, that’s where the usual mistakes are
- ^([a-za-z]+-?) +[a-zA-Z0-9]+\.[x|X][m|M][l|L]$
- Regular expressions for Chinese characters: [u4e00-u9fa5]
- Double byte characters: [^\x00-\ XFF] (including Chinese characters, can be used to calculate the length of the string (a double byte character length 2, ASCII character 1))
- Regular expression for blank lines: \n\s*\r (can be used to delete blank lines)
- Regular expressions for HTML tags: <(\S*?) [^ >]>.? | <.? /> (regular expression for the first and last whitespace characters: ^\s|\s*
A useful expression that can be used to delete whitespace characters at the beginning and end of a line - Tencent QQ id: [1-9][0-9]{4,} (Tencent QQ ID starts from 10000)
- China Postcode: [1-9]\d{5}(? ! \d) (6-digit Postal code for China)
- IPv4 address: ((2 (5 [0-5] | \ [0-4] d)) | [0, 1]? (\ d {1, 2}). ((2 (5 [0 to 5] | \ [0-4] d)) | [0, 1]? \ d {1, 2} {3}))