I am trying to remove all comments from a SQL string in javascript. I have this regex which removes almost all of them but there is an issue.
Please have a look on this link
https://regex101.com/r/JaEWKO/1
When there are nested multi line comments then the regex does not work as expected. The scenario has been mentioned in the link
I've gone through multiple links for this issue on stackoverflow ¯\_(ツ)_/¯
Regular expression to remove comments from SQL statement
and many others
here is the regex that im currently using
var sql = storedProc.replace(/(--.*)|(((\/\*)+?[\w\W]+?(\*\/)+))/g, '')
I expect it to remove all the comment from the string but it break in case of nested multi line comments.
Can anyone help me with this?