- 相關推薦
PHP正則匹配中文字母數字正則的表達式
PHP語言是一門實用性很強的語言,下面小編為大家帶來了關于PHP正則匹配中文字母數字正則的表達式,歡迎大家閱讀!
PHP正則匹配中文字母數字正則的表達式
代碼如下
if(preg_match("/^d*$/", "4312"))
{
echo "全數字
";
}
if(preg_match("/^[a-z]*$/i", "fdsFDfd"))
{
echo "全字母
";
}
if(preg_match("/^[a-zd]*$/i", "fd4fd34"))
{
echo "有數字有字母
";
}
中文漢字
代碼如下
$username=$_REQUEST['username'];
if(!preg_match("/^[a-z0-9xa1-xff]{3,10}$/",$username))
{
echo"34r345";
exit;
}
上面是比較散的,下面把幾個總結到一起來
代碼如下
$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 "";
exit;
}
if (!empty($leng)) {
echo "";
exit;
}
【PHP正則匹配中文字母數字正則的表達式】相關文章:
php漢字正則表達式06-03
PHP常用的正則表達式是什么10-07
php正則去掉php注釋07-30
PHP知識:正則表達式基礎知識10-14
java正則表達式10-24
PHP學習:正則表達式和字符串處理09-07
js正則表達式是什么05-27
php常用的驗證類以及正則實例08-27
幫助你駕馭Java正則表達式08-01
正則表達式過濾HTML危險腳本的實例09-22