如果就是匹配这3条,那直接用”https“匹配就行了。你肯定还有别的要求吧,最好说清楚,是不是域名必须是https://cloud.netlifyusercontent.com/assets/
开头,photos-数字.jpg
结尾等要求?
是的,有这个要求
@杨喂鱼:
string str = @"https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/15da9d15-e879-4b32-999c-07d17634cc0e/photos-01.jpg
https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/d1fbbd3f-99c1-455c-bbb8-6ff2a6d68e2b/photos-44.jpg
https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/bc7e12a0-6c2f-424e-84b4-034dc521317d/photos-81.jpg";
var result = Regex.Matches(str, @"^https\://cloud\.netlifyusercontent\.com/assets/\S+/photos-\d+\.jpg", RegexOptions.Multiline);
foreach (Match item in result)
{
Console.WriteLine(item.Value);
}
Console.ReadLine();
你最好研究下正则表达式这块儿,我也不是很懂,仅供参考
/^https\:\/\/cloud\.netlifyusercontent\.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/(15da9d15-e879-4b32-999c-07d17634cc0e\/photos-01|d1fbbd3f-99c1-455c-bbb8-6ff2a6d68e2b\/photos-44|bc7e12a0-6c2f-424e-84b4-034dc521317d\/photos-81)\.jpg$/
除这3条以外都不匹配