I am trying to extract the parameter variables :country and :age from this statement and store them in a string[] or List or something like that. But what is the easiest way to do that? Regex? String-Methods?
string sql = "select firstname, age, country from Table where country = :country and age > :age order by age";
My approach so far :
string[] sub = sql.Split(' ');
List<string> parameter = new List<string>();
for (int i = 0; i < sub.Length; i++)
{
if (sub[i].StartsWith(':'))
{
parameter.Add(sub[i]);
}
} //