Je voudrais construire une regex qui puisse me retourner la liste des tables
d'une requete SQL SELECT.
Par ex :
-SELECT * FROM tab1, tab2, tab3
-SELECT * FROM tab1, tab2 WHERE col="abc"
-SELECT * FROM tab1, tab2 LIMIT 1
J'ai essayé quelque chose comme ca :
---
Regex pattern1 = new
Regex(@"FROM\s+(?<tabname>.*)(WHERE|LIMIT|ORDER|HAVING|GROUP)?",
RegexOptions.IgnoreCase );
Match match1 = pattern1.Match(request);
if( match1.Success )
string res = match1.Groups["tabname"].Value;
---
Mais à chaque fois, dans tabname, j'ai toute la string jusqu'à la fin de la
chaine (ex : tab1, tab2 LIMIT 1) au lieu de (tab1, tab2)