.+
is greedy and consumes as many characters as it can.
.+?
is reluctant and consumes as few characters as it can.
- e.+d finds the longest substring that starts with e and ends with d (and contains at least one character in between). In your example extend cup end will be found.
- e.+?d find the shortest such substring. In your example, extend and end are two such non-overlapping matches, so it finds both.