import re


def get_infos_of_cat_link(link):
    """ 
        **get all category numbers from a given link**

        a link to a category is build up like this:
        https://dl.acm.org/topic/ccs2012/10003120.10003138.10003141?SeriesKey=imwut&expand=all

        first we remove everything after the ?

        https://dl.acm.org/topic/ccs2012/10003120.10003138.10003141

        then everthing before the last /

        10003120.10003138.10003141

        these 3 numbers indicate that this category has 2 parent categories
        these 3 numbers are then split by the . and are put into a list which is returned

        If a category number is later found more then once you can be sure that this is NOT a leaf category.
        This is because the link to the first parent category looks like this:

        https://dl.acm.org/topic/ccs2012/10003120.10003138

        **Args:**

        * link (link to a (sub-) category): 
            * this link contains all parent categories numbers

        **Returns:**
        
        * list(int): 
            * SList of Integers to all the parent categories
    """

    categories_numbers = []
    cat_string = re.sub(r"\?[\w*\W*]*","", link)

    cat_string = re.sub(r"[\w*\W*]*\/", "", cat_string)

    categories_numbers = re.split(r"\.", cat_string)

    return categories_numbers