import re

text = """cakes 10 are good.
cakes 10c are good.
cakes 20 21 22 are good.
cakes 30, 31, 32 are good.
cakes 40a, 40b, 40c are good."""

numerical = r"""
[0-9]{1,4}((\.|\-)?[A-Za-z])?   # max 4 digits followed optionally by a letter separated by , or - optionally.
"""

# those could be separated by:
separator = r"""(,?\s?)"""  # comma followed optionally by space

# code to get the matches with finditer
pattern2 = fr"""(({numerical} 
                (({separator})?|\s?))+
                |
                {numerical} # single case
                )"""
refs = re.finditer(pattern2, text, re.VERBOSE, )
for element in refs:
    print(element.group())