0
使用RegEx从大字符串中提取图片文件链接的最佳方法是什么?用于提取图像文件链接的RegEx
http://<linkhere>.jpg
http://<linkhere>.png
http://<linkhere>.gif
等等?但在一个表达?
使用RegEx从大字符串中提取图片文件链接的最佳方法是什么?用于提取图像文件链接的RegEx
http://<linkhere>.jpg
http://<linkhere>.png
http://<linkhere>.gif
等等?但在一个表达?
http://(\\S+?)\\.(jpg|png|gif)
例如为:
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);
}
啊 - 我张贴了我原来的评论之前,我看到了你的代码示例,所以我删除了我的意见。有一天我会学习耐心。感谢您的回答:) – Tim
:)不用担心:) –
C#的正则表达式引擎是否理解'\ s'和'\ S'?可能比'[^]'更好。 –