-
Notifications
You must be signed in to change notification settings - Fork 1
ParseArray
jdubs edited this page Oct 23, 2016
·
1 revision
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.
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;
}