比如我定义一个字符串是
string str=“AA类   BB类    CC类   DD类”;
用什么方法将这几个“XX类”依次一个个获得呢?

解决方案 »

  1.   

    string[]  result=str.split(new char[]{' '})   或者   Match match = Regex.Match(msg, "\S*类");  
      

  2.   

    string[] strArray = str.Split(new char[1] { ' ' });
      

  3.   

    用 MatchCollection match = Regex.Matches(AllTag, "\\S*类");解决了,就是没明白这个\S是什么意思...
      

  4.   

    正则规则符 \S 表示非空白字符 和空白字符 \s 正好相反
    互为相反的还有 \d \D,\w \W
      

  5.   

    用 MatchCollection match = Regex.Matches(AllTag, "\\S*类");解决了,就是没明白这个\S是什么意思...
    \S是正则中的非空字符
      

  6.   

    如下:
    string arr = {"AA类 ","  BB类",    "CC类",  "DD类"}
      

  7.   

    我完全明白你的用意,我之前也写过这样的代码不妨告诉你一下我的思路
                        string strTzbs = "为你的字符串";
                       你想要的结果:(strTzbs != "") ? strTzbs.Substring(strTzbs.LastIndexOf(dtMain.Rows[i]["这个为你的标示字段"].ToString()), 1).Trim() : "0"