I managed to find the regex for handling /* */ cases but it doesn't work well for -- cases. How can I change my regex to fix this?
var s = `SELECT * FROM TABLE_A
/* first line of comment
second line of comment */
-- remove this comment too
SELECT * FROM TABLE_B`;
var stringWithoutComments = s.replace(/(\/\*[^*]*\*\/)|(\/\/[^*]*)|(--[^*]*)/g, '');
/*
Expected:
SELECT * FROM TABLE_A
SELECT * FROM TABLE_B
*/
console.log(stringWithoutComments);
Thank you