Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of Ajax and PHP regular expression validation form and CAPTCHA

Shulou Source: shulou.com Published: 2022-06-03 20:23:32 11月12日 Update

This article mainly shows you the "Ajax and PHP regular expression verification form and CAPTCHA example analysis", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn "Ajax and PHP regular expression verification form and CAPTCHA sample analysis" this article.

Pattern match:

\: escape characters such as:\ b escaped b

^: regular expression start symbol

$: regular expression end symbol

*: match the preceding character 0 or n times

+: matches the preceding character once or n times

?: match the preceding character 0 or 1 times

Matches all single characters except newline characters

| |: or, for example, x | y matches x or y |

{n}: matches the first n characters

{nrecoery m}: match at least n and up to m preceding characters

[xyz]: matches any character in parentheses

[^ xyz]: matching is equivalent to [0-9] except for any character in square brackets

\ w: matching any number or letter or underscore is equivalent to [A-Za-z0-9 _]

\ d: matches any number between 0Murray 9

Pattern modifier:

I: ignore case

Examples of common regular expressions:

/ / the user name consists of 6-18 alphanumeric underscores and cannot start with a number.

Var r_name=/ ^ [a-z]\ w {5pm 17} $/ I

/ / the password length cannot be less than six digits.

Var r_pwd=/ ^\ w {6,} $/

/ / all general email addresses

Var r_eamil=/ ^\ walled @\ w+ (\.)\ wrought /

/ / match an address of QQ Mail

/ / 861745122@qq.com

Var r_qq_email=/ ^\ d {5,} @ qq (\.) com$/

/ / match an email address of 163

Var r_163_email=/ ^\ way.163 (\.) com$/

/ / match a suffix name that may be .com | .net | .cn | .edu

Var email=/ ^\ walled @\ w+ (\.) com | net | cn | edu$/

/ / A valid age group is required

Var r_age=/ ^\ d {1pc2} $/

/ / if (age > = 18&&age "= 100)

/ / verify the mobile phone number: 11 digits at the beginning of 13 15 18

Var r_tel=/ ^ 1 [3pr 5pr 8]\ d {9} $/

/ / verify the ID number of 18 digits or 17 digits plus an X

Var r_s=/ ^\ d {18} |\ d {17} xgarbage I

/ / verify Chinese var reg=/ ^ [\ u4e00 -\ u9fa5] {2pr 17} $/

/ / php

$reg = "/ ^ [\ x {4e00} -\ x {9fa5}] $/ u"

The following is an example: account basic information login account: gender: male and female account security settings login password: real name: email address:

Tags: Authentication character password mailbox regular login expression number account address format user user name certificate number identity example form analysis content name Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Tech Info Shulou Information Linux MariaDB