Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Reg Exp for selecting particular strings from a query

Hello, I would like to know which reg expr can extract relevant schema and table from the following query:

 

Query:

"--select * from vfde-project.schema1.table1
select * 
from vfde-project.schema2.table2;
--select * from vfde-project.schema3.table3
--select * from vfde-project.schema4.table4
select * from INFORMATION_SCHEMA.JOBS_TIMELINE"

 

SELECT 'a'  , REGEXP_EXTRACT_ALL(QUERY'vfde-project[a-zA-Z0-9_.-]+') as Object
FROM b
 
Expected result:
Nested table:
a, schema3.table3
a, schema4.table4
 
the reg expr above not provides this result.

Schemas in lines which are commented out (starting with '--') and Schemas='INFORMATION_SCHEMA' are not relevant and should be excluded from the result.

Thank you very much!

0 6 680
6 REPLIES 6