Move the common part in one place and limit the alternation to the part within the parentheses.

examples/regex/alternatives_with_grouping.py
from __future__ import print_function

import re

strings = [
   'apple pie',
   'banana pie',
   'apple'
]

for s in strings:
    match = re.search(r'(apple|banana) pie', s)
    if match:
        print('Matched in', s)