$action = trim($_GET['action']);
if($action == "sub")
{
$str = $_POST['dir'];
//if(!preg_match("/^[".chr(0xa1)."-".chr(0xff)."A-Za-z0-9_]+$/",$str)) //GB2312汉字字母数字下划线正则表达式
if(!preg_match("/^[x{4e00}-x{9fa5}A-Za-z0-9_]+$/u",$str)) //UTF-8汉字字母数字下划线正则表达式
{
}
else
{
}
}
//?>
<form method="POST" action="?action=sub">
输入字符(数字,字母,汉字,下划线):
<input type="text" name="dir" value="">
<input type="submit" value="提交">
</form>