Replace a paragraph in the <title> tags with c#
I am creating a function that can replace a paragraph in the tags and delete the scripts with tags, can you see the syntax I have written correctly? ----------------------------------------------------------------------------------------------- StreamReader tx = new StreamReader("page2.txt"); string title = Regex.Match("page2.txt", @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>", RegexOptions.IgnoreCase).Groups["Title"].Value; List<string> lines = new List<string>(); while (!tx.EndOfStream) lines.Add(tx.ReadLine()); string linetoreplace = lines[0]; string contents = tx.ReadToEnd(); StreamWriter sw = new StreamWriter(" how to ? thay the"); } public static void DelJs() { StreamReader tx = new StreamReader("page2.txt"); Regex rRemScript = new Regex(@"<script[^>]*>[\s\S]*?</script>"); newtx = rRemScript.Replace(oldtx, ""); return newtx; }