public static BasePattern CreatePattern(string patternText) { var result = PatternParsers.Regex(new ArrayConsList <char>(patternText)); if (result.Rest.IsEmpty) { return(result.Tree); } else { throw new ArgumentException( string.Format("Could not understand part of the regex pattern: {0}.", result.Rest.AsEnumerable().AsString().ShowVerbatim()), "patternText."); } }