コード例 #1
0
        public static bool ExistWord(this string actualString, string word,
                                     StringComparison stringComparisonMode, int startIndex = 0)
        {
            if (startIndex < 0 || startIndex > actualString.Length)
            {
                ExceptionGenerator.RunArgumentOutOfRangeException(startIndex, 0, actualString.Length);
            }
            int index = actualString.IndexOf(word, startIndex, stringComparisonMode);

            if (index >= 0)
            {
                if (index == 0 && word.Length == actualString.Length)
                {
                    return(true);
                }

                if (index > 0 && index + word.Length < actualString.Length)
                {
                    return(actualString[index - 1] == ' ' && actualString[index + word.Length] == ' ');
                }
                if (index > 0)
                {
                    return(actualString[index - 1] == ' ');
                }
                if (index + word.Length < actualString.Length - 1)
                {
                    return(actualString[index + word.Length] == ' ');
                }
            }
            return(false);
        }
コード例 #2
0
        public static bool CharOutQuots(this string actualString, int index, ref int nextQuotParaIndex,
                                        int startIndex = 0)
        {
            if (index < 0 || index > actualString.Length)
            {
                ExceptionGenerator.RunArgumentOutOfRangeException(index, 0, actualString.Length);
            }
            if (startIndex < 0 || startIndex > actualString.Length)
            {
                ExceptionGenerator.RunArgumentOutOfRangeException(startIndex, 0, actualString.Length);
            }
            int quotIndex = actualString.IndexOf('\"', startIndex);

            if (quotIndex == -1)
            {
                return(true);
            }

            int quotIndexEnd = actualString.IndexOf('\"', quotIndex + 1);

            if (quotIndex > index)
            {
                nextQuotParaIndex = quotIndex;
                return(true);
            }
            while (quotIndexEnd > -1 && quotIndexEnd < index)
            {
                quotIndex = actualString.IndexOf('\"', quotIndexEnd + 1);
                if (quotIndex == -1)
                {
                    break;
                }
                quotIndexEnd = actualString.IndexOf('\"', quotIndex + 1);
            }
            if (quotIndex > index)
            {
                nextQuotParaIndex = quotIndex;
                return(true);
            }
            if (quotIndexEnd < index)
            {
                nextQuotParaIndex = quotIndexEnd + 1;
                return(true);
            }
            if (quotIndexEnd > -1 && quotIndexEnd < index)
            {
                nextQuotParaIndex = quotIndexEnd + 1;
            }
            return(false);
        }
コード例 #3
0
        public static bool StringOutQuots(this string actualString, int leftIndex, int rightIndex,
                                          int startIndex = 0)
        {
            if (leftIndex < 0 || leftIndex > actualString.Length)
            {
                ExceptionGenerator.RunArgumentOutOfRangeException(leftIndex, 0, actualString.Length);
            }
            if (rightIndex < 0 || rightIndex > actualString.Length)
            {
                ExceptionGenerator.RunArgumentOutOfRangeException(rightIndex, 0, actualString.Length);
            }
            if (startIndex < 0 || startIndex > actualString.Length)
            {
                ExceptionGenerator.RunArgumentOutOfRangeException(startIndex, 0, actualString.Length);
            }

            int q_index = actualString.IndexOf('\"', startIndex);

            if (q_index == -1)
            {
                return(true);
            }

            int q_index_end = actualString.IndexOf('\"', q_index + 1);

            if (q_index > rightIndex)
            {
                return(true);
            }
            while (q_index_end > -1 && q_index_end < leftIndex)
            {
                q_index = actualString.IndexOf('\"', q_index_end + 1);
                if (q_index == -1)
                {
                    break;
                }
                q_index_end = actualString.IndexOf('\"', q_index + 1);
            }
            if (q_index_end < leftIndex || q_index > rightIndex)
            {
                return(true);
            }
            return(false);
        }