Answer to Question #235709 in C# for Fav

Question #235709

Write a program, which removes all HTML tags and retains only the text inside them. The output should be written into the file Covid-21.txt.


1
Expert's answer
2021-09-11T23:40:20-0400
using System;
using System.IO;
using System.Threading.Tasks;


class Main1{
static String remove_HTML_tags(String s)
{
	System.Text.RegularExpressions.Regex r =
	new System.Text.RegularExpressions.Regex("<[^>]*>");
	
	s = r.Replace(s, "");
	return s;
}


public static void Main(String []args)
{
	String s;
	s = "<div><h1>Hello world</h1></div>";
	
	File.WriteAllText("Covid-21.txt", remove_HTML_tags(s));
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS