I have a query and want to get table names between from & where
If its a single line and single table without alias i could do so:
(?<=from )([^#]\w*)(?=.*where)
I need to get each table except the prefixed table. i.e course c
marks s
But i can't figure out regex for the following Query.
(The where
clause could be in same line or new line, on start of line or with space or tab)
from #prefix#student, course c, marks m
where ....
There are also sub queries in some places, if that case could also be handled would help.
select ... from course c
where id = (select ... from student where ...)
I'm trying to find & replace in sublime text 3
editor
Test case queries:
//output [course]
select ... from course
where ...
//output [course c] [marks s]
select ... from course c, marks s
where ....
//output [marks m]
select ... from #prefix#course c, marks m
where ...
//output [student s]
select ... from #prefix#course c
where id = (select ... from student s where ...)