日期:2014-05-19  浏览次数:20710 次

求一个正则表达式.急.
string   s=   "ACb机构badasdf客户adsfaz经地 ";

要返回一个集合col
col[0]=机构
col[1]=客户
col[2]=经地

这个正则如何作?

谢谢.

------解决方案--------------------
string s = "ACb机构badasdf客户adsfaz经地 ";
List <string> list = new List <string> ();
System.Text.RegularExpressions.MatchCollection mc = System.Text.RegularExpressions.Regex.Matches(s, "[\u4e00-\u9fa5]* ");
foreach (System.Text.RegularExpressions.Match match in mc)
{
if (!string.IsNullOrEmpty(match.Value))
{
list.Add(match.Value);
}
}
------解决方案--------------------
try

string yourStr = "ACb机构badasdf客户adsfaz经地 ";
yourStr = Regex.Replace(yourStr, "^[^\u4e00-\u9fa5]*|[^\u4e00-\u9fa5]*$ ", " ");
string[] col = Regex.Split(yourStr, @ "[^\u4e00-\u9fa5]+ ");

------解决方案--------------------
string s = "ACb机构badasdf客户adsfaz经地ff ";
string[] a = Regex.Split(Regex.Replace(s, @ "^[\x00-\xff]*|[\x00-\xff]*$ ", " "), @ "[\x00-\xff]+ ");