using System.Collections.Generic;
using System.Text.RegularExpressions;
public static void Main()
var testError = "The element 'blah' has invalid child element 'blah 2'. List of possible elements expected: 'blah 3'. Error count: (1). First error found at Position 148801:...";
var alternateError = "The element 'hydrogen' is missing a neutron. Please replace with deuterium. Error count: (1). First error found at position 1628395613581...";
var errorFeed = new List<string>(){testError,testError,testError,alternateError,testError,testError};
var matchString = @"(?<=Error count: \().(?=\))";
var errorCountMatcher = new Regex(matchString);
var errors = new List<string>();
Console.WriteLine($"Number of actual errors: {errorFeed.Count}. Example error: {errorFeed[0]}");
foreach (var newError in errorFeed) {
int i = errors.FindIndex(error => error.StartsWith(newError.Substring(0, newError.IndexOf("Error count: ("))));
errors[i] = Regex.Replace(errors[i], matchString, (int.Parse(errorCountMatcher.Match(errors[i]).Value)+1).ToString());
Console.WriteLine($"\n\nFinal list has {errors.Count} errors:");
foreach (var error in errors) {
Console.WriteLine(error);