public static Tuple <string, int> GetSanitisedCardName(string rawCardName) { try { var namer = new Regex(@"\s*([0-9]+)x?\s+(.*)"); //download webpage //trim white space at ends, and merge white space string c = StringExtras.MergeWhiteSpace(StringExtras.CleanString(rawCardName)); int cardCount = 1; //try and scrape count var matches = namer.Match(c); if (matches.Groups.Count == 3) { cardCount = Int32.Parse(matches.Groups[1].Value); c = matches.Groups[2].Value; } //wrap each word with +[] var words = c.Split(null); c = words.Aggregate("", (current, w) => current + ("+[" + w + "]")); return(new Tuple <string, int>(c, cardCount)); } catch (Exception ex) { } return(null); }
/// <summary> /// returns card names and counts /// </summary> /// <param name="rawCardNames"></param> /// <returns></returns> public static List <Tuple <string, int> > GetSanitisedCardNames(string[] rawCardNames) { var ret = new List <Tuple <string, int> >(); var namer = new Regex(@"\s*([0-9]+)x?\s+(.*)"); //download webpage foreach (var cr in rawCardNames) { //trim white space at ends, and merge white space string c = StringExtras.MergeWhiteSpace(StringExtras.CleanString(cr)); int cardCount = 1; //try and scrape count var matches = namer.Match(c); if (matches.Groups.Count == 3) { cardCount = Int32.Parse(matches.Groups[1].Value); c = matches.Groups[2].Value; } //wrap each word with +[] var words = c.Split(null); c = words.Aggregate("", (current, w) => current + ("+[" + w + "]")); ret.Add(new Tuple <string, int>(c, cardCount)); } return(ret); }
private static string Clean(string instr) { var str1 = StringExtras.CleanString(instr); //manually replace weird shit str1 = str1.Replace("—", "-"); return(str1); }
public static void cleanMP3(TagHandlerUpdate TH) { TH.Title = StringExtras.CleanString(TH.Title); TH.Album = StringExtras.CleanString(TH.Album); TH.Artist = StringExtras.CleanString(TH.Artist); }