ParseArray

jdubs edited this page Oct 23, 2016 · 1 revision

Overview

Utilizing a regular expression, a formatted string is split into an array. Subsequently the values in each group attempt to retrieve a value from a variable matching the group value. If no match then the actual value is returned.

Source Code

internal static object[] ParseArray(object SourceArray)
{
	Regex reg = new Regex("{(?<tag>.*?)}");
	MatchCollection matches = reg.Matches((string)SourceArray);
	var str = new object[matches.Count]; var i = 0;
	foreach (Match m in matches)
	{
		try
		{
			str[i] = Variable(m.Groups["tag"].Value).Value;
		}
		catch
		{
			str[i] = m.Groups["tag"].Value;
		}
		i++;
	}
	return str;
}

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.