Goal:
Locate the the sentence "From today's featured article" from the website "http://en.wikipedia.org/wiki/Main_Page" using webscape with C# code.
Problem:
You retrieve website's soucecode inside of a string value.
I believe that you can locate the sentence "From today's featured article" by looping with substring. I have a feeling that it is a inefficient approach.
Is there a better solution to locate the sentence "From today's featured article" from the string input?
Info:
*I'm using C# code with Visual Studio 2013 community.
*The soucecode does not work properly. On the the first three row are working.
WebClient w = new WebClient();
string s = w.DownloadString("http://en.wikipedia.org/wiki/Main_Page");
string svar = RegexUtil.MatchKey(input);
static class RegexUtil
{
static Regex _regex = new Regex(@"$ddd$");
/// <summary>
/// This returns the key that is matched within the input.
/// </summary>
static public string MatchKey(string input)
{
//Match match = Regex.Match(input, @"From today's featured article", RegexOptions.IgnoreCase);
Match match = _regex.Match(input);
// Match match = regex.Match("Dot 55 Perls");
if (match.Success)
{
return match.Groups[1].Value;
}
else
{
return null;
}
}
}