using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace QC.QSPR.Text.RegularExpressions;

public class RegexUtility
{
	public static bool ExtractParameters(string regex, string data, Dictionary<string, string> outParameters)
	{
		Regex regex2 = new Regex(regex);
		if (!regex2.IsMatch(data))
		{
			return false;
		}
		Match match = regex2.Match(data);
		string[] groupNames = regex2.GetGroupNames();
		for (int i = 1; i < groupNames.Length; i++)
		{
			outParameters[groupNames[i]] = match.Groups[i].Value;
		}
		return true;
	}
}
