import re


def check_reg_matching(reg, stringa):
    """
    Check if a regular expression matches a given string

    Parameters
    -------------
    reg
        Regular expression
    stringa
        String

    Returns
    -------------
    boolean
        Matches or not?
    """
    if type(reg) is str:
        reg = re.compile(reg)

    match = re.match(reg, stringa)

    if match is not None:
        stru = str(match)
        if "match='" in stru:
            stru = str(match).split("match='")[1].split("'")[0]
        elif "match=\"" in stru:
            stru = str(match).split("match=\"")[1].split("\"")[0]
        else:
            raise Exception("match not contained in the match")
        if len(stru) == 0:
            #print(stru, stringa)
            #print(len(stru), len(stringa))
            #input()

            return False
        return True
    else:
        return False