How to extract table name from a query

Hello,

I have a query which is passing to the component as a parameter and I need to fetch the table names in that query .

eg :

select * from tableA inner join table B on col1=col2

I need the output as table A and table B

Can you help us on how to fetch the table names from the query