const regex = new RegExp('(?<=from|join|table|into|exists|update) (?!IF)(\\w+\\.*)+', 'img')
const str = `SELECT * FROM COLLECTIONNAME.SCHEMANAME.TABLENAME LEFT JOIN SCHEMANAME.TABLENAME ON A.D = B.D
CREATE TABLE IF NOT EXISTS SCHEMANAME.NEWTABLENAME, SCHEMANAME.NEWTABLENAME
ALTER TABLE SCHEMANAME.EXISTINGTABLENAME
CREATE TABLE table_name (column_1 datatype, column_2 datatype, column_3 datatype);
DELETE FROM table_name WHERE some_column = some_value;
INSERT INTO table_name (column_1, column_2, column_3) VALUES (value_1, 'value_2', value_3);
select * from A join (select top 5 * from B) on B.ID = A.ID where A.ID in (select ID from C where C.DOB = A.DOB)
Select distinct W.WORKER_ID, W.FIRST_NAME, W.Salary
from Table1 W, Table2 W1
where W.Salary = W1.Salary
and W.WORKER_ID != W1.WORKER_ID;
left `;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions