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.
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));
}
}
Comments
Leave a comment