示例#1
0
文件: soal.cs 项目: marax27/mtse
        static public int findFirstNotOf(string s, e_CharGroup which_chars, int start_pos = 0)
        {
            if (start_pos >= s.Length)
            {
                return(NPOS);
            }

            for (int i = start_pos; i != s.Length; ++i)
            {
                if (!belongsTo(s[i], which_chars))
                {
                    return(i);
                }
            }

            return(NPOS);
        }
示例#2
0
文件: soal.cs 项目: marax27/mtse
        static public string trimOffGivenChars(string s, e_CharGroup which_chars)
        {
            int start = 0;

            while (belongsTo(s[start], which_chars) && start < s.Length - 1)
            {
                ++start;
            }

            // Jesli caly string sklada sie z danych znakow, zwroc pusty string
            if (start == s.Length - 1)
            {
                return(String.Empty);
            }

            int finish = s.Length - 1;

            while (belongsTo(s[finish], which_chars) && finish > 0)
            {
                --finish;
            }

            return(s.Substring(start, finish - start + 1));
        }