function Is_email ($STR) {
Check Email
Return Preg_match ("/^\w+" ([-+.] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) *$/", $str);
}
function Is_url ($STR) {
Inspection website
Return Preg_match ("/^http:\/\/[a-za-z0-9]+\.[ a-za-z0-9]+[\/=\?%\ -&_~ ' @[\]\ ': +!] * ([^<>\])
*$/", $STR);
}
function Is_qq ($STR) {
Check QQ
Return Preg_match ("/^[1-9]\d{4,8}$/", $str);
}
function Is_zip ($STR) {
Inspection ZIP Code
Return Preg_match ("/^[1-9]\d{5}$/", $str);
}
function Is_idcard ($STR) {
Inspection ID
Return Preg_match ("/^\d{15} (\d{2}[a-za-z0-9])? $/", $STR);
}
function Is_chinese ($STR) {
Check whether it is Chinese
Return Ereg ("^[". Chr (0XA1). " -". Chr (0xff)." +$ ", $STR);
}
function Is_english ($STR) {
Test whether it is in English
Return Preg_match ("/^[a-za-z]+$/", $str);
}
function Is_mobile ($STR) {
Check if it's a cell phone
Return Preg_match ("/^ (\ (\d{3}\)) | ( \d{3}\-)) 13\d{9}$/", $str);
}
function Is_phone ($STR) {
BYOC, is that the phone?
Return Preg_match ("/^ (\ (\d{3}\)) | ( \d{3}\-))? (\ (0\d{2,3}\) |0\d{2,3}-)? [1-9]\d{6,7}$/],
$STR);
}
function Is_safe ($STR) {
Return (Preg_match ("/^ ([a-z]*|[ a-z]*|\d*| [-_\[email protected]#\$%\^&\*\.\ (\) \[\]\{\}<>\?\\\/\ ' \ "]*) |.
{0,5}) $|\s/", $str)! = 0);
}
}
Common regular expression collation for PHP forms