replace c-style comments with newlines (regexp)

lex __ comp_lexx at hotmail.com
Thu Dec 20 19:00:47 EST 2007


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 still use the original linenumbers (I want to use linenumbers as a reference for later use.)
I know that that will complicate things a bit more, so this is a bit less important.

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.  :( 

So, if you have an answer to this , please let me know how to do this!

thanks in advance,
- Alex



_________________________________________________________________
Download de nieuwe Windows Live Messenger!
http://get.live.com/messenger/overview


More information about the Python-list mailing list