I need a regex to pull out the table names from sql statements in jpl files. These are just text files. A simple example is:
sql select last_name, first_name, id from table_a
but this can also be like:
sql select a.last_name, b.first_name, a.id from table_a a, table_b b where a.id = b.id order by a.id
In this case I would need to pull out table_a and table_b from the statement.
This is a Windows XP system, currently I'm using perl but can change to somthing else if necessary. The statements always starts with sql. The statements can be all upper case or all lower case or a mix of the two. The table names can be [a-zA-Z_:]. There also maybe a select statement containing tables of the same format in the where clause enclosed by parenthesis. The main problem I'm having is everything after the 'FROM' followed by the first table name is really optional and can be multiple. If there is more than one table name there is always a comma separation and a where clause.