使用正则表达式计算字符串中中文字符的个数

System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex("[\u4e00-\u9fa5]", System.Text.RegularExpressions.RegexOptions.Multiline);

string strTemp = "随机产生了了多2333afadsg不筱个af575这样的了的算法";

MessageBox.Show(reg.Matches(strTemp).Count.ToString());
posted @ 2009-03-13 08:28  三角猫  阅读(433)  评论(2编辑  收藏  举报