Attached: regular quick lookup table
An expression for a checksum number
/ / digital
(/ ^ [0-9] * $/)
// N digits
(/^\d{n}$/)
// An m-n digit
(/^\d{m,n}$/)
// Numbers beginning with zero and non-zero
(/ ^ (0 | [1-9] [0-9] *) $/)
// A non-zero number with at most two decimal digits
(/ ^ ((1-9] [0-9] *) + (\. [0-9] {1, 2})? $/)
// A positive or negative number with 1-2 decimal places
(/ ^ (\ -)? \ d + (\ \ d {1, 2})? $/)
// Positive, negative, and decimal numbers
(/ ^ (\ | \ +)? \d+(\.\d+)? $/)
// A positive real number with two decimal places
(/ ^ [0-9] + (\. [0-9] {2})? $/)
// A positive real number with 1 to 3 decimal places
(/ ^ [0-9] + (\. [0-9] {1, 3})? $/)
// a non-zero positive integer
(/^[1-9]\d*$/) (/ ^ ((1-9] [0-9] *) $/ {1, 3}) (/ ^ \ +? [1-9] [0-9] * $) /)
// A non-zero negative integer
(/ ^ \ - [1-9] [0-9] * $/) (/^-[1-9]\d*$/)
// A non-negative integer
(/^\d+$/) (/^[1-9]\d*|0$/)
// A non-positive integer
(/^-[1-9]\d*|0$/) (/^((-\d+)|(0+))$/)
Copy the code
An expression to validate a character
/ / the Chinese characters
(/^[\u4e00-\u9fa5]{0,}$/)
// A string consisting of digits and 26 letters
(/^[0-9a-zA-Z]+$/)
// Contains 3 to 20 characters
($/ / ^. {3, 20})
// A string of 26 letters
(/^[a-zA-Z]+$/)
// A string of 26 letters, digits, and underscores (_)
(/^\w+$/)
// Chinese, English, and digits including underscores (_)
(/^[\u4E00-\u9FA5A-Za-z0-9_]+$/)
// Chinese characters, English characters, digits but not underscores
(/^[\u4E00-\u9FA5A-Za-z0-9]+$/)
// Can be entered with ^%&',; * =? \ "and other characters
(/^[%&',;\*=?\x22]+/)
// Do not enter characters containing ~
(/[^~\x22]+/)
Copy the code
Special requirement expression
/ / Email address
(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/) (/^\w+@\w+\.\w+$/)
// Mobile phone number
(/ ^ (13 14 15 16 17 | | | | | | 18 19) [0-9] {9} $/)
// Domestic telephone number (0511-4405222, 021-87888822)
(/\d{3}-\d{8}|\d{4}-\d{7}/)
// Id card number
(/^(\d{18}|\d{15}|(\d{17}(X|x)))$/)
// Whether the account is valid (starting with a letter, 5-16 bytes allowed, alphanumeric underscore allowed)
(/ ^ [a zA - z] {4, 15} $\ w /)
// Password (must start with a letter and contain 6 to 18 letters, digits, and underscores (_).)
(/ ^ \ [a zA - z] $/ w {5} in 2)
// Strong password (must contain a combination of uppercase and lowercase letters and digits, cannot use special characters, length between 8 and 10)
(/ ^ (? =.*\d)(? =.*[a-z])(? =. * [a-z]) [A zA - Z0-9] {8, 10} $/)
Copy the code