public static string TakeWhileNot(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 TakeWhileNot(this Subject subject, Func <char, bool> predicate, long max = int.MaxValue) { var start = subject.Index; var index = start; max = Math.Min(start + max, subject.Text.Length); while (index < max && !predicate(subject.Text[index])) { index += 1; } return(index > start?subject.Take(index - start) : ""); }
public static string TakeWhile(this Subject subject, char c, long max = int.MaxValue) { var start = subject.Index; var index = start; max = Math.Min(start + max, subject.Text.Length); while (index < max && subject.Text[index] == c) { index += 1; } return(index > start?subject.Take(index - start) : ""); }