Following is the string: (I'm getting that from config file so its not constant):
string sequence = "Concat({ACCOUNT_NUM},substring(FormatDate(yyyyMMddHHmmss,DateNow())
,2,12), GetLast(GetNextSequence(seq_relation),1))";
It contains multiple custom methods and I want them somewhere in the same order as they appear in the above string. Following is the strategy I applied:
string[] arbitrary = sequence .Split('(').ToArray();
string[] methodsNmore = arbitrary.Take(arbitrary.Length - 1).ToArray();
string[] array2 = methodsNmore.Where(strr => strr.Contains(',')).ToArray();
string[] methods = array2.Select(str => str.Substring(str.LastIndexOf
(',') + 1, str.Length - str.LastIndexOf
(',') - 1)
).ToArray();
for (int i = 0; i < methods.Length; i++)
{
string row = Array.Find(methodsNmore, item => item.Contains(methods[i]));
int ii = Array.IndexOf(methodsNmore, row);
methodsNmore[ii] = methods[i];
}
The resulting array, methodsNmore
, now contains only the names of methods in the same order as in above string sequence.
Is there any other elegant way of doing it?