static IEnumerable <string> Bangs() { yield return("NyaaBangs are (case insensitive) shorthands that can be used in patterns."); yield return("Currently supported NyaaBangs:"); foreach (string desc in BangShorthands.GetDescriptions()) { yield return(desc); } yield return(" -----"); }
// ---------------------------------------------------------------------------------------------------------- // In a sense also a helper function for PatternMatch, but this is the main function deciding whether a title // matches a pattern. // ---------------------------------------------------------------------------------------------------------- static bool IsMatch(string[] pattern, string title) { // Each pattern is an array of constituents. The title needs to contain each of them. string tmpTitle = title; foreach (string s in BangShorthands.ExpandPattern(pattern)) { int startIndex = tmpTitle.IndexOf(s, StringComparison.OrdinalIgnoreCase); if (startIndex >= 0) { // Addendum: if we have a match, remove it from the the tmpTitle, this to ensure that if we // have a pattern with repeated words it only matches when the title indeed contains // multiple instances of that word. tmpTitle = tmpTitle.Remove(startIndex, s.Length); } else { return(false); } } return(true); }