I want to get the links to the images from the img src in the html. I have a string of the html that I read into a method which returns an arraylist of the image urls.
Into the method I pass the string of html and the url of the webpage.
I need some help with the regex to get the image name with the extension. If you can help with matching against the html string that would be a bonus. I will accept the right answer or close to it, thank you all.
I heard about HTML parsers but I would rather use this way thank you.
here is my method:
private ArrayList GetImageLinks(String inputHTML, String link)
{
ArrayList imageLinks = new ArrayList();
var regex = new Regex(@"<img.*?src=[\"'](.+?)[\"'].*?");
//using http://gskinner.com/RegExr/ this regex seems to get: <img src="beach.png" for example. while I need just beach.png.
//match the regex to the html and get all the image links like: image5.png
//link = inputHTML + link
//add new link to arraylist
return imageLinks;
}