public static int CountWhileNot(this string str, int start, CharSet chars, long max = int.MaxValue)
 {
     var index = start;
     max = Math.Min(index + max, str.Length);
     while (index < max && !chars.Contains(str[start]))
     {
         index += 1;
     }
     return index - start;
 }
Example #2
0
        public static int CountWhileNot(this string str, int start, CharSet chars, long max = int.MaxValue)
        {
            var index = start;

            max = Math.Min(index + max, str.Length);
            while (index < max && !chars.Contains(str[start]))
            {
                index += 1;
            }
            return(index - start);
        }
 public static int CountWhileNot(this Subject subject, CharSet chars, long max = int.MaxValue)
 {
     var start = subject.Index;
     var index = start;
     max = Math.Min(start + max, subject.Text.Length);
     while (index < max && !chars.Contains(subject.Text[index]))
     {
         index += 1;
     }
     return index - start;
 }
Example #4
0
        public static int CountWhileNot(this Subject subject, CharSet chars, long max = int.MaxValue)
        {
            var start = subject.Index;
            var index = start;

            max = Math.Min(start + max, subject.Text.Length);
            while (index < max && !chars.Contains(subject.Text[index]))
            {
                index += 1;
            }
            return(index - start);
        }
Example #5
0
        public static string TakeWhile(this Subject subject, CharSet chars, long max = int.MaxValue)
        {
            var start = subject.Index;
            var index = start;

            max = Math.Min(start + max, subject.Text.Length);
            while (index < max && chars.Contains(subject.Text[index]))
            {
                index += 1;
            }
            return(index > start?subject.Take(index - start) : "");
        }
 public static string TakeWhile(this Subject subject, CharSet chars, long max = int.MaxValue)
 {
     var start = subject.Index;
     var index = start;
     max = Math.Min(start + max, subject.Text.Length);
     while (index < max && chars.Contains(subject.Text[index]))
     {
         index += 1;
     }
     return index > start ? subject.Take(index - start) : "";
 }