The following method of verifying username is that the username must consist of a letter with a number of dashes, let's take a look at the example below.
1. Check that the user name is in accordance with the provisions of "more than two letters, numbers, or underline", the code is as follows:
/**
* Check User name compliance * *
@param STRING $username user name to check
* @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 (< $strlen | | | $strlen < 2)
{return
false;
}
return true;
Two-digit letters, numbers, or underscores : ^[a-za-z0-9_\x7f-\xff][a-za-z0-9_\x7f-\xff]+$.
Note: Here, the letters are a-z,a-z, and the ASCII characters from 127 to 255 (0X7F-0XFF)
2, Password:6-20 digits, composed of letters, numbers, code 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 verification , the 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 for everyone to share the user registration information: User name, password and the regular expression of the mailbox verification, I hope you seriously learn this "PHP user registration information validation Regular expression", will be harvested.