1、网址链接:
http://bbs.csdn.net/topics/310058604
2、
[\u4e00-\u9fa5]:指所有中文的匹配
\w:所有英文大小写及数字、下划线的匹配,相当于[_a-zA-Z0-9]
即用户名 2~20个字符,支持中文、英文、数字、“_”、“-”
正则表达式如下:^[\u4e00-\u9fa5\w-]{2,20}$
代码判断:
using
System.Text.RegularExpressions;
// 正则表达式对象
Regex re =
new
Regex(
@"^[\u4e00-\u9fa5\w]+$"
);
// 是否找到匹配
bool
yesorno = re.IsMatch(
"your string"
);