匹配中文:[\u4e00-\u9fa5]英文字母:[a-zA-Z]数字:[0-9]匹配中文,英文字母和数字及_:
^[\u4e00-\u9fa5_a-zA-Z0-9]+$
^[\u4e00-\u9fa5_a-zA-Z0-9]+$
解决方案 »
- asp.NET中如何获取收到的HTTP请求的Accept Header值
- cache丢失 已经记录的原因,但是不知道怎么引起,大家帮忙看看
- 请教高手--动态SQL语句问题!
- Request.ServerVariables("server_name") asp与asp.net的写法有何不同?
- 在线诚等解答!关于CheckBox的问题!
- 给大家提供一个支持.net的虚拟主机和域名注册网站,价格很便宜
- 请问在自定义控件中如何将xmlns:v="urn:schemas-microsoft-com:vml"写到html标签中
- 这到底是不是编码的问题呀?
- 怎么写验证日期合法的函数
- 各位老大,请教个问题,关于图片显示的
- 如何从datagrid中选取多项数据
- 请教数据库连接问题
Regex reg = new Regex("^[\u4e00-\u9fa5_a-zA-Z0-9]+$");
bool flag = reg.IsMatch(filename);
if(flag == false)
{
return filename;
}
else
{
return "0";
}
if(flag == false)
==>
if(!flag)
using System.Text.RegularExpressions;
class TestPattern
{
static bool IsMatch(string filename)
{
Regex reg = new Regex("^[\u4e00-\u9fa5_a-zA-Z0-9]+$");
return reg.IsMatch(filename);
}
public static void Main()
{
Console.WriteLine(IsMatch("123.edb")); //False
Console.WriteLine(IsMatch("%&%(&%(%%")); //False
Console.WriteLine(IsMatch("abc")); //true
}
}