import re


def count_regex_occurances(reg, text):
    """
    Counts the number of a given regex in a given text.
    This can be used, for example, for finding the counts of certain patterns (e.g. quotes or URLs).
    """
    return len(list(re.findall(reg, text)))