Suppose I had the string \"1 AND 2 AND 3 OR 4\", and want to create an array of strings that contains all substrings \"AND\" or \"OR\", in order, found within the string.
<
Here's a goofy way that I came up with:
string rule = "1 AND 2 AND 3 OR 4";
List andsOrs = new List();
string[] split = rule.Split();
for (int i = 0; i < split.Length; i++)
{
if (split[i] == "AND" || split[i] == "OR")
{
andsOrs.Add(split[i]);
}
}
string[] conditions = andsOrs.ToArray();
return conditions;