RegEx for extracting image file links
What would be the best way to use RegEx to extract links of picture files from a large string?
http开发者_StackOverflow://<linkhere>.jpg
http://<linkhere>.png
http://<linkhere>.gif
etc.? But in one expression?
http://(\\S+?)\\.(jpg|png|gif)
e.g.:
string s = "http://link1.jpg bha http://link2.png blahblah http://link3.gif";
foreach (Match m in Regex.Matches(s, "http://(\\S+?)\\.(jpg|png|gif)"))
{
Console.WriteLine(m.Groups[1].Value);
}
精彩评论