static List<string> GetTable(string sql)
{
sql = sql.Replace("'", "\"");
List<string> tables = new List<string>();
Regex regex = new Regex(@"((?![^(]*\))(?![^']*')(?i)(?:FROM|JOIN)\s+([\w\.]+))", RegexOptions.Multiline);
MatchCollection matches = regex.Matches(sql);
foreach (Match match in matches)
{
tables.Add(match.Groups[2].Value);
}
return tables;
}
网友评论