I am aware of this: Regex to remove comments from SQL Query String using JavaScript
Which I thought as the answer, but that still leaves the newline which I also need to remove:
sql = `HELLO 1
-- comments 1
HELLO 2
-- comments 2
HELLO3
`;
sql.replace(/.*--.*/g,'');
But this still leaves spaces and does not remove the whole line:
HELLO 1
HELLO 2
HELLO3
What I am looking for is this:
HELLO 1
HELLO 2
HELLO3
How can I achieve this in the regex without executing a second replace to replace blank lines ?