Im working on teradata log analysis and faced with issue that a lot of queries have comments. Can somebody help in REGEXP_REPLACE defiinition or may be advice some other way how to do it?
So task is to remove/replace query part with (it can be in any position in sql and may repeat):
- --text
- /* text */
I spent a lot of time on it and stil no good results.
I tried to use REGEXP_REPLACE but faced with problems:
- how to difine 'end of line'. for comments difiend as '--text'. Beginning -- till 'end of line'
- how to deal with several comments in query?
CodePudding user response:
Findout how to do it:
RegExp_Replace(SqlTextInfo,'[\t\r\n]|(--[^\r\n]*)|(/\*[\w\W]*?(?=\*/)\*/)')