In this regex I'm trying to extract the list of tables from a SQL select statement. It works fine with one exception, if the statement ends with the table name there is no match. For example:
Given he regex:
(?:from|join)\s+(.*?)(?:\)|\s+(?:where|on|inner|outer|full|left|right|join|\s*$))
and given this string:
"select xxxx from table1 t1, table2, table3 t3 " (note the last space)
The match is:
"table1 t1, table2, table3 t3"
But given this string:
"select xxxx from table1 t1, table2, table3 t3" (without last space)
There's no match. How to make this work?
[DataBase].[dbo].[TableName](SQL Server) or`TableName`in MySQL (just for two examples your regex won't hit). Subqueries as well (select * from (select * from table)). I'm afraid regular expressions are not the right tool for this job.select count(*) from ( select foo.bar, baz.foo from foo, (select foo from herp) baz)? If so, matching just won't do it.