Php user registration information verification regular expression, user registration regular expression _ PHP Tutorial

Source: Internet
Author: User
The php user registration information verifies the regular expression, and the user registers the regular expression. The php user registration information verifies the regular expression. the regular expression below the regular expression is used to verify the user name. The principle is that such a user name must be a regular expression verified by the php user registration information with a number and a fixed line, user registration regular expression

The following regular expression is used to verify the user name. The user name must be composed of a sequence with a fixed number. let's take a look at the example below.

1. check the user nameWhether it meets the "two or more letters, numbers, or underscores" requirement. the code is as follows:

/*** Check whether the user name meets the requirements ** @ param STRING $ username the user name to be checked * @ return TRUE or FALSE */function is_username ($ username) {$ strlen = strlen ($ username); if (! Preg_match ("/^ [a-zA-Z0-9 _ \ x7f-\ xff] [a-zA-Z0-9 _ \ x7f-\ xff] + $/", $ username) // open source software: phpfensi.com {return false;} elseif (20 <$ strlen | $ strlen <2) {return false;} return true ;}

Two or more letters, numbers, or underscores: ^ [A-zA-Z0-9 _ \ x7f-\ xff] [a-zA-Z0-9 _ \ x7f-\ xff] + $.

Note: Here the letter is a-z, A-Z, and ASCII characters from 127 to 255 (0x7f-0xff)

2. password:It consists of 6 to 20 digits and consists of letters and numbers. the code is as follows:

function isPWD($value,$minLen=5,$maxLen=16){ $match='/^[\\~!@#$%^&*()-_=+|{}\[\],.?\/:;\'\"\d\w]{'.$minLen.','.$maxLen.'}$/'; $v = trim($value); if(emptyempty($v)) return false; return preg_match($match,$v); } 

3. email verificationThe code is as follows:

function isEmail($value,$match='/^[\w\d]+[\wd-.]*@[w\d-.]+\.[\w\d]{2,10}$/i'){ $v = trim($value); if(emptyempty($v)) return false; return preg_match($match,$v); } 

This article will share with you the user registration information: username, password, and regular expression for mailbox verification. I hope you will learn this article carefully, the regular expression for verifying php user registration information.

The following is a regular expression used to verify the user name. The user name must be a fixed-line string with numbers in the sequence...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.