Files
WireMock.Net-wiremock/src/WireMock.Net/Util/RegexUtils.cs
Stef Heyenrath f358f13c08 Solved issues #204 #205 #200
* Lower priority from Proxy mappings

* Fix codefactor

* extra tests

* #205

* Fix test for linux

* `c:\temp\x.json` fix

* Extra tests

* more tests

* more tests

* codefactor

* #200

* refactor

* refactor

* tests
2018-09-22 08:41:24 +02:00

25 lines
715 B
C#

using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace WireMock.Util
{
internal static class RegexUtils
{
public static Dictionary<string, string> GetNamedGroups(Regex regex, string input)
{
var namedGroupsDictionary = new Dictionary<string, string>();
GroupCollection groups = regex.Match(input).Groups;
foreach (string groupName in regex.GetGroupNames())
{
if (groups[groupName].Captures.Count > 0)
{
namedGroupsDictionary.Add(groupName, groups[groupName].Value);
}
}
return namedGroupsDictionary;
}
}
}