const regex = new RegExp('(;)', 'g')
const str = `DELETE FROM import WHERE NOT recstatus;
ALTER TABLE import DROP COLUMN IF EXISTS erreur;
ALTER TABLE import ADD COLUMN erreur TEXT;
DROP TRIGGER IF EXISTS line_error_seek_trigger ON import;
DROP FUNCTION IF EXISTS line_error_seek();
CREATE OR REPLACE FUNCTION line_error_seek() RETURNS TRIGGER AS \$errors_by_line\$
BEGIN
blabla;
blablabla;
IF blabla
bla blaaaaaa;
END IF;
RETURN bla;
END;
\$errors_by_line\$ language 'plpgsql';
CREATE TRIGGER line_error_seek_trigger
BEFORE UPDATE ON import
FOR EACH ROW
EXECUTE PROCEDURE line_error_seek();
DROP FUNCTION IF EXISTS table_error_seek();
CREATE OR REPLACE FUNCTION table_error_seek() RETURNS INTEGER AS \$errors_by_table\$
BEGIN
blabla;
blablabla;
RETURN bla;
END;
\$errors_by_table\$ LANGUAGE plpgsql;
SELECT * FROM table_error_seek();`;
// 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