php正则匹配gb2312和utf-8中文
栏目:php教程时间:2014-02-09 14:17:40
- <?php
- $action = trim($_get['action']);
- if($action == "sub")
- {
- $str = $_post['dir'];
-
- if(!preg_match("/^[x{4e00}-x{9fa5}a-za-z0-9_]+$/u",$str))
- {
- echo "<font color=red>您输入的[".$str."]含有违法字符</font>";
- }
- else
- {
- echo "<font color=green>您输入的[".$str."]完全合法,通过!</font>";
- }
- }
- ?>
------分隔线----------------------------
------分隔线----------------------------