I'm attempting to use regex to grab a URL from some HTML but it isn't working.
<h3 class="(.*?)"><a onmousedown="(.*?)" href="(.*?)">(.*?)</a></h3>
Could someone help me with this and explain it, I'm not the best with Regex and I would like to actually see where I went wrong..
EDIT:
I'm not "grabbing" code from anywhere. I have known about regex for a long time but I've never done much with it, I figured It could come in handy for this project so I gave it a shot. Here is my code:
static void Main(string[] args)
{
WebClient wc = new WebClient();
String html = wc.DownloadString("http://www.example.com/");
foreach (String result in match("<h3 class=\"(.*)\"><a onmousedown=\"(.*)\" href=\"(.*)\">(.*)</a></h3>", html))
{
Console.WriteLine("result: " + result);
}
Console.ReadKey();
}
public static ArrayList match(string regex, string html, int x = 0)
{
ArrayList l = new ArrayList();
foreach (Match m in new Regex(regex, RegexOptions.Multiline).Matches(html))
{
l.Add(m.Groups[x].Value);
}
return l;
}
some crap here
`? – cHao May 23 '13 at 01:09