I always assumed regex worked like this, but I guess I never hit a case like this until now and I'm not sure the best way to tackle it.
String to consider:
You can use this negative lookahead based on tempered greedy token regex in python:
reg = re.compile(r'apple(?:(?!apple).)*cat', re.DOTALL)
(?:(?!apple).)* will match 0 or more any character that don't have
apple at next position thus making sure we don't have
apple in our match. Note that negative lookahead will be asserted for each character in the match.