To determine whether it is a pure letter in php, we can directly use the regular /^[a-zA-Z]$/ to verify, including uppercase and lowercase letters. Students who need to know more can refer to it.
Upload the code
The code is as follows
代码如下 |
复制代码 |
header('Content-type: text/html; charset=utf-8');
$str = "dasdadsfsadASDSADS";
if (preg_match('/^[a-zA-Z]+$/',$str))
{
echo $str."是字母";
}
else
{
echo $str."不是字母";
}
?>
|
|
Copy code
|
代码如下 |
复制代码 |
preg_match('/^[a-zA-Z]+$/',$str) |
header('Content-type: text/html; charset=utf-8');
$str = "dasdadsfsadASDSADS";
代码如下 |
复制代码 |
if(preg_match("/^d*$/", "4312"))
{
echo "全数字
";
}
if(preg_match("/^[a-z]*$/i", "fdsFDfd"))
{
echo "全字母
";
}
if(preg_match("/^[a-zd]*$/i", "fd4fd34"))
{
echo "有数字有字母
";
}
|
| if (preg_match('/^[a-zA-Z]+$/',$str))
{
echo $str."is a letter";
}
else
{
echo $str."Not a letter";
}
?>
This is the code
Returns TRUE if it is a letter, otherwise returns FALSE
Other judgments
The code is as follows
|
Copy code
if(preg_match("/^d*$/", "4312"))
{
echo "All numbers
";
}
if(preg_match("/^[a-z]*$/i", "fdsFDfd"))
{
echo "Full letters
";
}
http://www.bkjia.com/PHPjc/631265.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631265.htmlTechArticleTo determine whether it is a pure letter in php, we can directly use the regular /^[a-zA-Z]$/ Come and verify, including uppercase and lowercase letters. Students who need to know more can refer to it. The code above is as follows...
|
|