private SetMatchesVariable ( Regex regex, Match match ) : void | ||
regex | Regex | |
match | Match | |
Résultat | void |
private void SetMatchesVariable(Regex regex, Match match)
{
var matches = new Hashtable();
var groupNames = from name in regex.GetGroupNames()
where match.Groups[name].Success
select name;
foreach (string name in groupNames)
{
int num;
if (int.TryParse(name, out num))
{
matches.Add(num, match.Groups[num].Value);
}
else
{
matches.Add(name, match.Groups[name].Value);
}
}
ExecutionContext.SetVariable("Matches", PSObject.AsPSObject(matches));
}