JS regular expressions 强:字母+数字+特殊字符 ^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&*]+$)(?![a-zA-z\d]+$)(?![a-zA-z!@#$%^&*]+$)(?![\d!@#$%^&*]+$)[a-zA-Z\d!@#$%^&*]+$ In: Letters + numbers, letters + special characters, numbers, special characters + ^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&*]+$)[a-zA-Z\d!@#$%^&*]+$ Weak: pure digital, pure letters, special characters pure ^(?:\d+|[a-zA-Z]+|[!@#$%^&*]+)$ // check whether the whole of digits function isDigit(s) { var patrn = / ^ [0-9] {1,20} $ /; if (!patrn.exec(s)) return false return true } // check the login name: Enter only 5-20 begin with a letter, can take numbers, "_" string "." function isRegisterUserName(s) { var patrn = / ^ [a-zA-Z] {1} ([a-zA-Z0-9] | [._]) {4,19} $ /; if (!patrn.exec(s)) return false return true } function isRegisterUserName(s) { var patrn = / ^ [a-zA-Z] {1} ([a-zA-Z0-9] | [._]) {4,19} $ /; if (!patrn.exec(s)) return false return true } // check User Name: Enter only 1-30 string beginning with the letter The Javascript code function isTrueName(s) { var patrn = / ^ [a-zA-Z] {1,30} $ /; if (!patrn.exec(s)) return false return true } }} // check Password: Enter only 6-20 letters, numbers, underscores function isPasswd(s) { var patrn = / ^ (\ w) {6,20} $ /; if (!patrn.exec(s)) return false return true } // check ordinary telephone and fax numbers: You can "+" at the beginning, in addition to numbers, may contain "-" function isTel(s) { // var patrn = / ^ [+] {0,1} (\ d) {1,3} []? ([-]? (\ D) {1,12}) + $ /; var patrn = / ^ [+] {0,1} (\ d) {1,3} []? ([-]? ((\ d) | []) {1,12}) + $ /; if (!patrn.exec(s)) return false return true } // check the phone number: You must start with a number, in addition to numbers, may contain "-" function isMobil(s) { var patrn = / ^ [+] {0,1} (\ d) {1,3} []? ([-]? ((\ d) | []) {1,12}) + $ /; if (!patrn.exec(s)) return false return true } // check zip code function isPostalCode(s) { // var patrně = / ^ [a-zA-Z0-9] {3,12} $ /; var patrně = / ^ [a-zA-Z0-9] {3,12} $ /; if (!patrn.exec(s)) return false return true } // check keyword search function isSearch(s) { var patrn=/^[^`~!@#$%^&*()+=|\\\][\]\{\}:;'\,.<>/?]{1}[^`~!@$%^&()+=|\\\] [\]\{\}:;'\,.<>?]{0,19}$/; if (!patrn.exec(s)) return false return true } function isIP(s) //by zergling { var patrn = / ^ [0-9.] {1,20} $ /; if (!patrn.exec(s)) return false return true } Regular Expressions ^ \\ d + $ // non-negative integer (integer + 0) ^ [0-9] * [1-9] [0-9] * $ // positive integer ^ ((- \\ d +) | (0 +)) $ // non-positive integer (negative integer + 0) ^ - [0-9] * [1-9] [0-9] * $ // negative integer ^ -? \\ d + $ // integer ^ \\ d + (// non-negative floating point number (floating-point number n + 0) ^(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*))$ // positive 浮点 number ^ ((- \\ d + (// non-positive float (negative float + 0) ^(-(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*)))$ // 负浮 score ^ (-? \\ d +) (// float ^ [A-Za-z] + $ // string consisting of the 26 English letters ^ [AZ] + $ // string of uppercase letters 26 composed of ^ [Az] + $ // string of 26 lowercase letters consisting of ^ [A-Za-z0-9] + $ // string of digits and letters of the English 26 String ^ \\ w + $ // digital, 26 English letters or the underscore ^ [\\ w -] + (// email address ^ [A-zA-z] +: // (// url ^ [A-Za-z0-9 _] * $ The full domain name matching regular expression: [A-zA-Z0-9] [- a-zA-Z0-9] {0,62} (\. [A-zA-Z0-9] [- a-zA-Z0-9] {0,62 }) + \.
Reprinted from: https://www.cnblogs.com/bluesky1024/p/8609196.html