您的位置:首页 > 其它

判断一个字符串中中文和字母或数字的个数

2012-06-02 17:47 218 查看
using System.Text.RegularExpressions;

private string GetResult(string str)

{

int len=str.Length;

str=Regex.Replace(str,"[a-zA-Z]","");

string result=(len-str.Length)+"个字母 ";

len=str.Length;

str=Regex.Replace(str,"[0-9]","");

result+=(len-str.Length)+"个数字 ";

len=str.Length;

str=Regex.Replace(str,"[\u4e00-\u9fa5]","");

result+=(len-str.Length)+"个中文";

return result;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: