in reply to need regex help to strip things like embedded C comments
printf("remember, /* this isn't a comment */"); printf("/* This isn't a comment %s */", /* but this is */ "/* this isn +'t, though */); // /* The code between these lines int x = y + z; // is not commented out. The line level comments take precedent */
In short, this is a potentially nasty problem. I would strongly recommend you read the very excellent Mastering Regular Expressions from O'Reilly by Jeffrey Friedl.
Regardless, any solution you come up with using regexes will probably only operate on a carefully crafted subset of the data, so proceed with caution. There are also variations depending upon which implementation of C you're using.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: need regex help to strip things like embedded C comments
by Eradicatore (Monk) on Jul 21, 2007 at 23:29 UTC |