in reply to [OT] Macro Problem

Maybe use Perl to expand your source code instead of C macros? I'm sure it wouldn't be too hard to search and replace the expression.

Most likely you want to look at Text::Balanced to parse the bracketed expressions. The rest should be some basic string manipulation.

If you have concrete problems with your Perl code, please post it and some small but relevant input and output data, and how it fails for you.