C#查找指定字符串的个数

Posted 棉晗榜

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C#查找指定字符串的个数相关的知识,希望对你有一定的参考价值。

转载
https://www.cnblogs.com/benpao/p/3308905.html

查找指定字符串的个数

            //查找@@字符串的个数
            string q = "AAA@@BBBB@@ASDSDF@@GGG@@";

            //方式一
            string[] arr = q.Split(new string[] { "@@" }, StringSplitOptions.RemoveEmptyEntries);
            int len2 = arr.Length;//@@的个数

            //方式二
            int len = System.Text.RegularExpressions.Regex.Matches(q, "@@").Count;

以上是关于C#查找指定字符串的个数的主要内容,如果未能解决你的问题,请参考以下文章