I'm attempting to convert a C# method to .Net code and I'm having some trouble. Here's the C# line
text = Regex.Replace(text, "{{(.+?)}}", new MatchEvaluator(match => values[match.Groups[1].Value].ToString()));
My first attempt looks like so:
$text = New-Object System.Text.RegularExpressions.MatchEvaluator -ArgumentList @({$values[$args[0].Groups[1].Value].ToString()})
I obviously don't understand how to create delegates in Powershell, and I've been googling for the past hour. Everything I come across seems to fail, so I'm sure I have a fundamental misunderstanding of what's going on. I know MatchEvaluator is itself a delegate type and I think the issue is I don't know how to create delegates from powershell scriptblocks. I keep getting exceptions complaining the method paramenter is null, but I know for a fact that what I'm passing to it isn't null, so I'm lost.
Can anyone help out here?