Following on from a previous question in which I asked:
How can I use a regular expression to match text that is between two strings, where those two
Try replacing the last .*? with: (?!(.*unwanted text.*))
Did it work?