matcher = re.compile('^[ \\t]*#define(.*\\\\\\n)+.*$', re.MULTILINE)

def extractDefines(s):
    mo = matcher.search(s)
if not mo:
    print(mo)
return
print(mo.group(0))
extractDefines(TEST1)
extractDefines(TEST2)
extractDefines(TEST3)
extractDefines(TEST4)
python regex to match multi-line preprocessor macro