private void RenameIdentifiers MatchCollection matches Regex Matches c

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
private void RenameIdentifiers()
{
MatchCollection matches = Regex.Matches(code, @"(var|function) (\w+)");
foreach (Match match in matches)
{
Console.WriteLine(match.Value);
string oldName = match.Groups[2].Value;
string newName = namesManager.NextName;
string pattern = @"(\W)" + oldName + @"(\W)";
string replacement = "$1" + newName + "$2";
code = Regex.Replace(code, pattern, replacement);
}
}