I have a code that:
reads a text file
replaces all lines who looks like "xx.xx.xx" to "date"
saves a new file with changes.
static void Main(string[] args) { RegexOptions options = RegexOptions.None; Regex regex1 = new Regex(@"\d{2}\.\d{2}\.\d{2}", options); string FilePath = @"C:\Users\User\Desktop\download1.txt"; string OutputhFilePath = @"C:\Users\User\Desktop\nf\download11.txt"; List<string> lines = new List<string>(); lines = File.ReadAllLines(FilePath).ToList(); var sb = new StringBuilder(); foreach (string line in lines) { string line2 = regex1.Replace(line, "date"); sb.AppendLine(line2); File.AppendAllText(OutputhFilePath, line2); } File.WriteAllText(OutputhFilePath, sb.ToString()); Console.ReadLine();
but what should I add so that the code does not replace the found lines to "date", but swap the first two characters of "xx.xx.xx" to the last two characters, for example: 29.06.20 to 20.06.29.
Thanks in advance!