public static void PrintResult(this Regex r, FileToChange s) { int i = 0, j = 0; Console.Write(s.base_Path); MatchCollection coll = r.Matches(s.OldName); List <string> whites = r.Split(s.OldName).ToList(); if (coll.Count > 0 && !string.IsNullOrWhiteSpace(s.OldName.Substring(0, coll[0].Index))) { Console.Write(whites[0]); j++; } if (string.IsNullOrEmpty(whites[0])) { whites.RemoveAt(0); } while (i < coll.Count || j < whites.Count) { if (i < coll.Count) { Program.PrintWithColor(coll[i].Value, ConsoleColor.Red); } if (j < whites.Count) { Console.Write(whites[j]); } i++; j++; } Console.Write(s.Extension); Console.WriteLine(); }
private static void ShowMatches() { string[] list = Directory.GetFiles(Path); var sr = new Regex(SelectedRegex); var files = new List <FileToChange>(); foreach (string f in list) { FileToChange file = new FileToChange(f); files.Add(file); sr.PrintResult(file); } Console.Write("\n\n - change matches with " + NewValue + " ?[y/n]"); string s = Console.ReadLine().Trim().ToLower(); if (s == "y") { foreach (FileToChange item in files) { item.SubmitChanges(sr, NewValue); } } }