Method 1
The code is as follows
if(preg_match("/^d*$/", "4312"))
{
echo "All numbers
";
}
if(preg_match("/^[a-z]*$/i", "fdsFDfd"))
{
echo "Full letters
";
}
if(preg_match("/^[a-zd]*$/i", "fd4fd34"))
{
echo "There are numbers and letters
";
}
Chinese characters
The code is as follows
$username=$_REQUEST['username'];
if(!preg_match("/^[a-z0-9xa1-xff]{3,10}$/",$username))
{
echo "34r345";
exit;
}
The above is relatively scattered, let’s summarize a few together
The code is as follows
$input_tag = $_POST['tag'];
$input_tag = explode(',', $input_tag);
$input_tag = array_unique($input_tag);
$input_tag = array_diff($input_tag, array(null));
$leng = '';
$true = '';
$comma = '';
foreach ($input_tag as $v) {
If (strlen($v) > 18) {
$leng .= $comma . $v;
$comma = ',';
}
$true .= $comma . $v;
$comma = ',';
}
$true = str_replace(',', '', $true);
if (!preg_match('/^[x80-xff_a-zA-Z0-9]+$/', $true)) {
echo "<script>alert('Special symbols not allowed!!!');</script>";
exit;
}
if (!empty($leng)) {
echo "<script>alert('A label can only be within 6 Chinese characters!!!');</script>";
exit;
}