I\'ve a text file containing large number of queries. I want to get all the distinct tables used in the entire file in all the queries. The table name can come after a \'fro
I'd use:
r = new Regex("(from|join)\s+(?\S+)", RegexOptions.IgnoreCase);
once you have the Match object "m", you'll have the table name with
m.Groups["table"].Value
example:
string line = @"select * from tb_name join tb_name2 ON a=b WHERE x=y";
Regex r = new Regex(@"(from|join)\s+(?\S+)",
RegexOptions.IgnoreCase|RegexOptions.Compiled);
Match m = r.Match(line);
while (m.Success) {
Console.WriteLine (m.Groups["table"].Value);
m = m.NextMatch();
}
it will print:
tb_table
tb_table2
- 热议问题