Moving beyond the whole perl/regex thing, what about just running the c pre processor on it?
The only downside there I see is possible text matching #defines that you don't want to get replaced, but I would think matching what cpp considers a #define would be vastly simpler then matching comments..
Comment on Re: removing C style comments from text files
Well yes, but it expands because you #include files. From his description (text files) I assumed that they weren't actual C programs and wouldn't be using the rest of the pre-processor commands. So there wouldn't be any #includes to expand the file size so dramatically. Beyond that I also suggested that it might be easier to match anything the pre-processor would consider a #define/#include, since the rules for that are fairly strict as I recall.