Came up with this merging all the others answer and with my use case.
(?ims)\b(?:FROM|JOIN|UPDATE|INTO)\s+(\w+(?:\.\w+)*)
it also fetch things like INFORMATION_SCHEMA.TABLES if you use postgres or something that regroups tables.
the following test string I used to test
SELECT columnA, columnB, columnC
FROM (
SELECT t1.columnA as columnA, t1.columnB as columnB
FROM table1 t1
UNION
SELECT t2.columnA as columnA, t2.columnB as columnB
from table2 t2
) as tu
left JOIN table3 t3 ON (tu.columnA = t3.columnA)
WITH temporaryTable (averageValue) as
(SELECT avg(Attr1)
FROM Table),
SELECT Attr1
FROM Table
WHERE Table.Attr1 > temporaryTable.averageValue;
Select ' Select productid,price'||
' from '|| table_name ||
' Union' quer
From tabs
Where table_name like 'table%';
Select ' Select productid,price'+
' from '+ table_name +
' Union' quer
From INFORMATION_SCHEMA.TABLES
where table_name 'table%';
Select ' Select productid,price'+
' from '+ table_name +
' Union' quer
From INFORMATION_SCHEMA.TABLES.test
where table_name 'table%';