Candor.StringExtensions.TrimStartNotIn C# (CSharp) Method

TrimStartNotIn() public static method

Trims any characters from the start of a string that is not in the supplied list.
public static TrimStartNotIn ( this text, IList chars ) : string
text this The text to be scanned.
chars IList The characters to be kept, such as a LexicalCharacterSet characters list.
return string
        public static string TrimStartNotIn(this string text, IList<char> chars)
        {
            if (string.IsNullOrWhiteSpace(text))
                return text == null ? null : string.Empty;

            while (text.Length > 1 && !chars.Contains(text[0]))
            {
                text = text.Substring(1);
            }
            if (text.Length == 1 && !chars.Contains(text[0]))
                return string.Empty;
            return text;
        }