Question: I have a very large SQL query. I am trying to scrape tables names using javascript out of SQL query. (I provide SQL query in a text file as input)

```
  select t1.name, t1.id, t1.address, t2.units,t2.sale
  from SCHMEA1.candy_customers_azim_056 as t1
  inner join SCHEMA1.candy_sales_history_set t2
    on (t1.custid = t2.ORIGTN_ACCT_NO)

```

What could be the regular expression to achieve something like this ? 

```
Tables:
candy_customers_azim_056 as t1
candy_sales_history_set t2

```

Answer: 
```
(from|join)\s+\w+\.((\w*)[as ]+(\w+))

```

should return what you're looking for in the second capture group.
You may try this one as well:

```
/(from|join)\s+(\w+\.)?(\w+)(\s+as)?(\s+\w+)?/gmi

```

You can see examples [here](https://regex101.com/r/av7fpW/3).