What follows is a regular expression I have written to match multi-line pre-processor macros in C / C++ code. I'm by no means a regular expressions guru, so I'd welcome any advice on how I can make this better.
Here's the regex:
^\s*#define(.*\\\n)+[\S]+(?!\\)It should match all of this:
#define foo(x) if(x) \ doSomething(x)
But only some of this (shouldn't match the next line of code:
#define foo(x) if(x) \ doSomething(x) normalCode();
And also shouldn't match single-line preprocessor macros.
I'm pretty siure that the regex above works - but as I said, there probably a better way of doing it, and I imagine that there are ways of breaking it. Can anyone suggest any?