Exemple #1
0
        private static string IndexOfAll(string text, string value, bool ignoreCase)
        {
            String8 text8  = text.TestConvert();
            String8 value8 = value.TestConvert();

            StringBuilder result = new StringBuilder();

            int nextIndex = 0;

            int[] matches = new int[2];
            while (true)
            {
                int matchCount = text8.IndexOfAll(value8, nextIndex, ignoreCase, matches);

                for (int i = 0; i < matchCount; ++i)
                {
                    if (result.Length > 0)
                    {
                        result.Append(", ");
                    }
                    result.Append(matches[i]);
                }

                if (matchCount < matches.Length)
                {
                    break;
                }
                nextIndex = matches[matchCount - 1] + 1;
            }

            return(result.ToString());
        }