
30 Jul
2006
30 Jul
'06
7:52 p.m.
Rene Rivera wrote:
Comment looking substring embedded in string constants:
const char *x = "/* something"; /* whatever */
And comments within comments:
/**/ something /*/ another /**/
/** something(); //*/ another(); /**/
/* something /* another */
Probably more combinations possible :-)
Can't you deal with these by first replacing all the instances of a single regular expression that matches both strings and comments with something appropriate? Something like: /\*.*?\*/|//[^\r\n]*|"(?:[^\r\n"\\]|\\.)" Because the matches won't overlap it should get this right.