I'm trying to take html code from a page on the internet, save it as a text file, then read the text file find a part of the code, save it as a var and out put it to the console in c#.
this is the code i'm trying but it doesn't work
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
class StringSearch
{
static void Main()
{
string HTML = System.IO.File.ReadAllText(@"C:\Users\gamer\Desktop\HTML\code test.txt");
string sPattern = "code";
foreach (string s in HTML)
{
System.Console.Write("{0,24}", s);
if (System.Text.RegularExpressions.Regex.IsMatch(s, sPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
{
System.Console.WriteLine(" (match for '{0}' found)", sPattern);
}
else
{
System.Console.WriteLine();
}
}
System.Console.WriteLine("Press any key to exit.");
System.Console.ReadKey();
}
}
}
P.S if you know a way to capture a pages HTML code/part of a pages HTML code and out put it that would be even better Thanks