H
Horizon
Hi,
I would like to build a regex that returns me the table list of a SQL SELECT
request like :
-SELECT * FROM tab1, tab2, tab3
-SELECT * FROM tab1, tab2 WHERE col="abc"
-SELECT * FROM tab1, tab2 LIMIT 1
I tried something like that :
---
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;
---
But, each time, in tabname, I get all the string to EOF.
For ex , in SELECT * FROM tab1, tab2 LIMIT 1
I get "tab1, tab2 LIMIT 1" instead of "tab1, tab2"
Thanks,
Horizon
I would like to build a regex that returns me the table list of a SQL SELECT
request like :
-SELECT * FROM tab1, tab2, tab3
-SELECT * FROM tab1, tab2 WHERE col="abc"
-SELECT * FROM tab1, tab2 LIMIT 1
I tried something like that :
---
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;
---
But, each time, in tabname, I get all the string to EOF.
For ex , in SELECT * FROM tab1, tab2 LIMIT 1
I get "tab1, tab2 LIMIT 1" instead of "tab1, tab2"
Thanks,
Horizon