Regular expression to remove comments from SQL statement

后端 未结 8 1783
时光说笑
时光说笑 2020-12-15 12:51

I\'m trying to come up with a regular expression to remove comments from an SQL statement.

This regex almost works:

(/\\*([^*]|[\\r\\n]|(\\*+([^*/]|         


        
8条回答
  •  情话喂你
    2020-12-15 13:20

    For Node.js, see pg-minify library. It works with PostgreSQL, MS-SQL and MySQL scripts.

    It can handle all types of comments, plus compress the resulting SQL to its bare minimum, to optimize what needs to be sent to the server.

提交回复
热议问题