import re


def img_bib_parser(imgbib):
    """
    Parser for the contents of imgbibs tags.
    Example: <imgbib>138-140</imgbib>

    :param imgbib: a string
    :return: a list of ints with the numbers of images where the list of references is for a book.
    """
    # case of multiple intervals
    bib = list()
    if not imgbib or imgbib == "None" or len(imgbib) < 1:
        return []
    for b in imgbib.split(";"):
        b = b.strip()
        if "-" in b:
            interval = b.split("-")
        else:
            interval = b.split(".")
        for n,i in enumerate(interval):
            if len(i) < 1:
                del interval[n]
                continue
            i = i.strip()
            # remove all non-numbers
            i = re.sub(r"\D", "", i)
            try:
                i = int(i)
            except:
                print(i)
            interval[n] = i
        if len(interval) > 1:
            bib.extend(range(interval[0], interval[1]+1))
        else:
            bib.append(interval[0])
    return bib