This article mainly introduces information about Ajax and PHP regular expression verification forms and verification codes. it is very good and has reference value. if you need it, you can refer to the following pattern matching characters:
\: Escape character, for example, \ B escaped B
^: Regular expression start symbol
$: End symbol of the regular expression
*: Match the previous character 0 or n times
+: Match the previous character once or n times
? : Match the previous character 0 times or 1 time
.: Match all single characters except line breaks
|: Or, for example, x | y matches x or y.
{N}: match the previous n characters
{N, m}: match at least n to a maximum of m prefix characters
[Xyz]: match any character in brackets
[^ Xyz]: match any character except the brackets is equivalent to [0-9]
\ W: match any number, letter, or underline is equivalent to [A-Za-z0-9 _]
\ D: match any number between 0 and 9
Pattern modifier:
I: case insensitive
Examples of common regular expressions:
// The username consists of 6-18 digits, which cannot start with a number.
Var r_name =/^ [a-z] \ w {5, 17} $/I
// The password length cannot be less than six characters
Var r_pwd =/^ \ w {6,} $/
// All common email addresses
Var r_eamil =/^ \ w + @ \ w + (\.) \ w + $/
// Match a QQ email address
// 861745122@qq.com
Var r_qq_email =/^ \ d {5,} @ qq (\.) com $/
// Match a 163 email address
Var r_163_email =/^ \ w + @ 163 (\.) com $/
// Matching a suffix may be. com |. net |. cn |. edu
Var email =/^ \ w + @ \ w + (\.) com | net | cn | edu $/
// Enter a valid age group
Var r_age =/^ \ d {1, 2} $/
// If (age> = 18 & age & lt; = 100)
// Verification mobile phone number: 11-digit, 13-digit, 15-18
Var r_tel =/^ 1 [3, 5, 8] \ d {9} $/
// Verify that the ID card number is 18 or 17 digits plus an X
Var r_s =/^ \ d {18} | \ d {17} x $/I
// Verify the Chinese var reg =/^ [\ u4e00-\ u9fa5] {2, 17} $/
// Php
$ Reg = "/^ [\ x {4e00}-\ x {9fa5}] $/u"
The following is an example: