Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何用特定值C替换MatchCollection中的每个特定值#_C#_Regex - Fatal编程技术网

C# 如何用特定值C替换MatchCollection中的每个特定值#

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

我使用正则表达式查找HTML中的所有标记,我想用列表中的一个新标记替换其中的每个标记

尝试:

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方法匹配的重载是什么?。