怎么用正则表达式获取 图片路径中的一部分

2025-06-24 12:36:41
推荐回答(1个)
回答1:

代码测试如下: //获取Src内容
string StrPage = @" 你的字符串。。";
Regex re = new Regex("| )", RegexOptions.IgnoreCase);
MatchCollection matches = re.Matches(StrPage);
string _tmpImageUrl = "";
foreach (Match mh in matches)
{
_tmpImageUrl = mh.Groups[3].Value;//src里面的路径
}。。。。。。。。。。。。测试结果:tmpImageUrl = /project/userfiles/image/ppt1.jpg