I'm looking for a regex that will match all the bold text below in a PHP (PCRE) compatible pattern, this is just an example query that it needs to match, so it can't be so specific that it won't work on other similar queries.
select a.*, (select count(*) from table1 ) as t1, (select count(*) from table2 ) as t2, (select count(*) from table3 ) as t3, col1, col2 from table4 as a LEFT JOIN ( SELECT g2.*,g1.id from table5 ) as g ON ( a.id = g.id ) );
UPDATE: My idea was to match the word FROM that is not between any brackets and everything before it. The end goal is to replace all the bold text with "COUNT()" for a database abstraction layer.