In the following code, the pattern is reading text between specified tags and I want to replace text in between those specified tags. I tried but replacing in whole file.
string input = File.ReadAllText(@"D:\text\div.txt");
string pattern = @"<body.*?>(.|\n)*?</body>";//reads text between specified tags
MatchCollection matches = Regex.Matches(input, pattern);
// Console.WriteLine("Matches found: {0}", matches.Count);
input = input.Replace("oldvalue", "newvalue");
File.WriteAllText(@"D:\text\div.txt", input);
if (matches.Count > 0)
foreach (Match m in matches)
Console.WriteLine(m.Groups[0]);
Console.ReadLine();
plz help me
thanks in advance