I'm trying to get the tables and aliases of a SQL select statement, for example the following select:
select * from table1 t1, table2, table3 t3, table4 where column = 1
should return two capturing groups, the first one table1
, table2
, table3
and table4
. The second capturing group t1
, null, t3
and null.
My attempt returns only the first item of each capturing group:
from\s+([^ ,]+)\s*(\w+)*,
returns table1
and t1
only. How to expand the regex to retrieve all the occurrences?