Re: replace c-style comments with newlines (regexp)

2007-12-21 Thread Peter Otten
Steven D'Aprano wrote: On Fri, 21 Dec 2007 00:00:47 +, lex __ wrote: I'm tryin to use regexp to replace multi-line c-style comments (like /* this /n */ ) with /n (newlines). I tried someting like re.sub('/\*(.*)/\*' , '/n' , file) but it doesn't work for multiple lines.

Re: replace c-style comments with newlines (regexp)

2007-12-21 Thread Neil Cerutti
On 2007-12-21, lex __ [EMAIL PROTECTED] wrote: I'm tryin to use regexp to replace multi-line c-style comments (like /* this /n */ ) with /n (newlines). I tried someting like re.sub('/\*(.*)/\*' , '/n' , file) but it doesn't work for multiple lines. besides that I want to keep all

Re: replace c-style comments with newlines (regexp)

2007-12-21 Thread Fredrik Lundh
lex __ wrote: background: I'm trying to create a 'intelligent' source-code security analysis tool for c/c++ , python and php files, but filtering the comments seems to be the biggest problem. :( for C/C++, why not just use gcc -E source.c (or equivalent), and use the line markers to

replace c-style comments with newlines (regexp)

2007-12-20 Thread lex __
I'm tryin to use regexp to replace multi-line c-style comments (like /* this /n */ ) with /n (newlines). I tried someting like re.sub('/\*(.*)/\*' , '/n' , file) but it doesn't work for multiple lines. besides that I want to keep all newlines as they were in the original file, so I can

Re: replace c-style comments with newlines (regexp)

2007-12-20 Thread Steven D'Aprano
On Fri, 21 Dec 2007 00:00:47 +, lex __ wrote: I'm tryin to use regexp to replace multi-line c-style comments (like /* this /n */ ) with /n (newlines). I tried someting like re.sub('/\*(.*)/\*' , '/n' , file) but it doesn't work for multiple lines. Regexes won't cross line