I have the following SQL text in a file. the objective is to identify database tables names from the files. Below is just a generic example and I am looking for a generic solution, either in C# or Perl. I am not done lot of regex therefore I would appreciate if someone gives me a start
select
a.xyz,
b.xyz,c.xyz,
d.xyz
from db1.test1 a
inner join db2.test2 b
on a.xyz = b.xyz
inner join
(
select a.xyz
from db1.test3) as c
on a.xyz=c.xyz
left outer join db1.test4 d
on c.xyz = d.xyz
so basically, i need to automate finding out names of all tables in the SQL. in this case, test1, test2, test3 and test4
I know that pattern is the tables names are preceded by either "from" , "inner join", "left outer join" , then a databasename (such as db1, db2 etc) , then a literal '.' and the table name.