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'?可能比'[^]'更好。 –