开发者

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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜