Replace a paragraph in the <title> tags with c# | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

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; }

17th Oct 2017, 4:03 PM
Olioty
Olioty - avatar
5 Answers
0
someone ?
17th Oct 2017, 4:31 PM
Olioty
Olioty - avatar
0
...
17th Oct 2017, 4:55 PM
Olioty
Olioty - avatar
0
???
17th Oct 2017, 10:26 PM
Olioty
Olioty - avatar
0
????
18th Oct 2017, 6:42 AM
Olioty
Olioty - avatar
0
nobody else ?
18th Oct 2017, 2:22 PM
Olioty
Olioty - avatar