C# 如何用特定值C替换MatchCollection中的每个特定值#
我使用正则表达式查找HTML中的所有标记,我想用列表中的一个新标记替换其中的每个标记 尝试:C# 如何用特定值C替换MatchCollection中的每个特定值#,c#,regex,C#,Regex,我使用正则表达式查找HTML中的所有标记,我想用列表中的一个新标记替换其中的每个标记 尝试: while (regx.IsMatch(html) && count < urls.Count) { newhtml = regx.Replace(newhtml, m => $"<img style='width:{Application.Current.MainPage.Width -10}' src={urls[count]} />"); c
while (regx.IsMatch(html) && count < urls.Count)
{
newhtml = regx.Replace(newhtml, m => $"<img style='width:{Application.Current.MainPage.Width -10}' src={urls[count]} />");
count++
}
while(regx.IsMatch(html)和&count$);
计数++
}
这将使所有图像成为相同的图像您必须在
regx.Replace()
中指定1
,以仅替换第一次出现的图像
while (regx.IsMatch(newhtml) && count < urls.Count)
{
newhtml = regx.Replace(newhtml, m => $"<img style='width: {Application.Current.MainPage.Width -10}' src={urls[count]} />", 1);
count++;
}
while(regx.IsMatch(newhtml)和&count$”,1);
计数++;
}
Replace方法匹配的重载是什么?。