Exemplo n.º 1
0
        public static int Find(this string text, char[] find, int index = 0, SymbolPair[] brackets = null)
        {
            if (String.IsNullOrWhiteSpace(text))
                return -1;

            var balancer = new BracketsBalanceStringValidator(brackets);
            for (int i = index; i < text.Length; i++)
            {
                if (find.Contains(text[i]) && balancer.IsBalanced)
                    return i;

                balancer.Push(text[i].ToString());
            }

            return -1;
        }
Exemplo n.º 2
0
        public static List<string> Split(this string text, char[] separators, SymbolPair[] brackets = null)
        {
            if (String.IsNullOrWhiteSpace(text))
                return null;

            var result = new List<string>();

            var input = text;
            while (!String.IsNullOrWhiteSpace(input))
            {
                var index = input.Find(separators, 0, brackets);

                var value = (index < 0) ? input : input.Substring(0, index);

                result.Add(value);

                input = input.Crop(value.Length + 1);
            }

            return result;
        }