import re
num  = fr"""(\d\d)([A-Z])?"""
sep  = fr"""and |or |, """

#pattern composition
pattern = fr"""{num}(?:\s*(?:{sep})\s*{num})*"""

text= """biscuits 10 are good
biscuits 20 and 30 are good
biscuits 40 and hot dog are good
but this one 50A and 50B and not ok"""

refs = re.finditer(pattern, text, re.VERBOSE,)
for ref in refs:
    TEXT = ref.group()
    print(TEXT)
