在php 中:
//GB2312漢字字母數字下划線正則表達式
GBK:
preg_match("/^[".chr(0xa1)."-".chr(0xff)."A-Za-z0-9_]+$/",$str);
//UTF-8漢字字母數字下划線正則表達式
UTF-8:
preg_match("/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]+$/u",$str);
//匹配手機號碼
//據悉,目前移動號段主要為134-139、150-152、158-159、182、187、147、157和188號段;
//聯通號段為130、131、132、155、156、185(尚未啟用)、186;電信號段為133、153、180(尚未放號)、189。
preg_match("/^13[0-9]{1}\d{8}$|15[012356789]{1}\d{8}$|18[2789]{1}\d{8}$|147\d{8}$/",$submit['telephone']);
在javascript中:
/^[\u4e00-\u9fa5]+$/.test(str)