比如有字符串:"ABCABCABCAAEEABCWSDEABC"通过什么函数能知道:ABC有函数几次?另外,用split("ABC")为什么不能是string?只能是char

解决方案 »

  1.   

    string str="ABCABCABCAAEEABCWSDEABC";
    string str1="ABC";
    int count=0;
    for(int i=0;i<=str.LastIndexOf(str1);i++){
    i=str.IndexOf(str1,i);
    count++;
    }
      

  2.   

    using System.Text.RegularExpressions;string str33 = "ABCABCABCAAEEABCWSDEABCA";
    //可以按ABC来分组
    string[] ary33 = Regex.Split(str33,"ABC",RegexOptions.IgnoreCase);Regex r33 = new Regex("ABC");
    //获取重复的次数
    int int33 = r33.Matches(str33).Count;
      

  3.   

    呵呵,原来C#中的split并不能像VB6中的split函数一样使用了..谢谢大家噢.