The following are some of the regular expressions that are frequently used by you for your reference. Only numbers are allowed: & quot; ^ [0-9] * $ & quot; only numbers of n digits are allowed: & quot; ^ d {n} $ & quot; only numbers with at least n digits can be entered: & quot; ^ d {n, }$ & quot; only m ~ Below are some of the regular expressions that are frequently used in the collection for future reference. Only numbers are allowed: "^ [0-9] * $". only numbers of n digits are allowed: "^ \ d {n} $". only numbers of at least n digits are allowed: "^ \ d {n ,}$" can only input m ~ N-digit number: "^ \ d {m, n} $" only numbers starting with zero and non-zero can be entered: "^ (0 | [1-9] [0-9] *) $" you can only enter a positive number with two decimal places: "^ [0-9] + (. [0-9] {2 })? $ "Only 1 ~ Positive number of three decimal places: "^ [0-9] + (. [0-9] {1, 3 })? $ "Only non-zero positive integers can be entered:" ^ \ +? [1-9] [0-9] * $ "only a non-zero negative integer can be entered: "^ \-[1-9] [0-9] * $" only three characters can be entered: "^. {3} $ "only A string consisting of 26 English letters can be entered:" ^ [A-Za-z] + $ "only A string consisting of 26 uppercase English letters can be entered: "^ [A-Z] + $" can only enter a string consisting of 26 lower-case letters: "^ [a-z] + $" can only be a string consisting of a number and 26 English letters: "^ [A-Za-z0-9] + $" only a string consisting of digits, 26 letters, or underscores can be entered: "^ \ w + $" verify user password: "^ [a-zA-Z] \ w {5, 17} $" correct format: starts with a letter and ranges from 6 ~ It can only contain characters, numbers, and underscores to verify whether it contains invalid characters ^ (?: [\ U4e00-\ u9fa5] * \ w * \ s *) + $ only Chinese characters can be entered: "^ [\ u4e00-\ u9fa5] {0 ,} $ "verification Email address:" ^ \ w + ([-+.] \ w +) * @ \ w + ([-.] \ w + )*\. \ w + ([-.] \ w +) * $ "verify InternetURL:" ^ http: // ([\ w-] + \.) + [\ w-] + (/[\ w -. /? % & =] *)? $ "Chinese phone number verification matching format: 0511-4405222, 021-87888822, 021-44055520-555, or (0511) 4405222 regular expression" (d {3, 4 }) | d {3, 4 }-)? D {7, 8} (-d {3}) * "China postal code verification matching form: 215421 regular expression" d {6} "email verification matching form: justali@justdn.com regular expression "w + ([-+.] w +) * @ w + ([-.] w + )*. w + ([-.] w +) * "ID card verification matching format: regular expression "d {18} | d {15}" regular expression for digit verification "d {n}" n is the specified length "d {n, m} "The length range from n to m is invalid. character verification matches and removes invalid characters, such as: Regular expression ^ (?: [\ U4e00-\ u9fa5] * \ w * \ s *) + $ Date verification matching format: 20030718,030718 range: 1900--2099 regular expression (19) {1} | (20) {1}) d {2}) | d {2 }) [01] {1} d {1} [0-3] {1} d {1} use instance: View code print
010203Example of php regular expression collection04