# Matches C/C++ #define (?m)\#\s{0,} define # Match the define \s+ # Whitespace (?\w+) # The identifier \s{0,} # Optional Whitespace # Then either (?>(?([^\\]+$ # A Line with no escape OR |(?[^\\]+?\\(?=(?>\r\n|\n))) # One or more lines ending with \ {1,})))