In my code I find all matches elements and replace it with special values.
Regex imgRule = new Regex("img id=\\\".+?\\\"");
MatchCollection matches = imgRule.Matches(content.Value);
string result = null;
foreach (Match match in matches)
result = match.Value;
if (result != null)
{
var firstOrDefault = node.ListImages.FirstOrDefault();
if (firstOrDefault != null)
{
var htmlWithImages = content.Value.Replace(result, string.Format("img src='{0}' class='newsimage' width='300'", firstOrDefault.ImageUrlId));
node.Content = htmlWithImages;
}
}
But, my code is wrong because if there is more than one match it replace only the last one, how can I correct my code for replace all matches in text?
content? Where is it declared? What is the type ofnode? Where is it declared?