Based on your comments, I'm pretty sure the issue is that you're applying your match to individual lines, rather than to the whole text at once. A zero-width negative lookahead (which you're using, with (?!\d)) will match successfully if the newline is the last character in the input string, which will be the case if your code is working line by line. The lookahead basically says "match if not followed by a digit". That is always true if there is nothing left in the input string.
You can't change the regex to fix this issue. Nothing you check on a single line can tell you what the contents of the next line will be, so you'll need to change your surrounding code in some way. One approach would be to read and transform the whole text rather than just a single line at a time. Or you could use something like the pairwise recipe from itertools to examine two lines at a a time, and examine the second line to decide if you needed to transform the first line.
I'd also like to note that substituting with \1 is not appropriate, since you have no capturing group (the parentheses in your pattern are part of the zero-width lookahead syntax, not grouping syntax). You should just be substituting with an empty string (which is effectively what you're doing anyway, since the back-reference doesn't refer to anything).
\r?\n(?!\d)demo. Is this demo working the way you expect?