Re: [GENERAL] regexp_replace to remove sql comments

2015-10-28 Thread Tom Lane
Mike writes: > Thanks with a bit of moving stuff about I think thats sorted it - in > case anyone every needs it: >SELECT > query, > trim(regexp_replace( > regexp_replace( > regexp_replace(query,'\/\*.+\*\/','','g'), > '--[^\r\n]*', ' ', 'g') > ,

Re: [GENERAL] regexp_replace to remove sql comments

2015-10-28 Thread Mike
Thanks with a bit of moving stuff about I think thats sorted it - in case anyone every needs it: SELECT query, trim(regexp_replace( regexp_replace( regexp_replace(query,'\/\*.+\*\/','','g'), '--[^\r\n]*', ' ', 'g') , '\s+', ' ', 'g')) as q FROM publ

Re: [GENERAL] regexp_replace to remove sql comments

2015-10-28 Thread Marc Mamin
> >Von: pgsql-general-ow...@postgresql.org >[pgsql-general-ow...@postgresql.org]" im Auftrag von "Mike >[m...@wolman.co.uk] >Gesendet: Mittwoch, 28. Oktober 2015 20:04 >An: pgsql-general@postgresql.org >Betreff: [GENERA

[GENERAL] regexp_replace to remove sql comments

2015-10-28 Thread Mike
Hi, I am trying to clean up the query field returned by the pg_stat_statements extension and remove all comments. Some of the queries in the query field contain comments like '-- some comment' and also '/* c style comments */' I have managed to strip off the '--' comments and also white spa