import re


def is_valid_regex(regex_pattern):
    """
    test that the given pattern is a valid regular expression
    """
    result = True

    if type(regex_pattern) is not str:
        result = False

    else:
        # check curly brackets (compile function won't throw an exception)
        open = len([e for e in regex_pattern if e == "{"])
        close = len([e for e in regex_pattern if e == "}"])
        if open == close:
            try:
                re.compile(regex_pattern, re.IGNORECASE)
            except:
                result = False
        else:
            # unbalanced curly brackets, invalid statement
            result = False

    return result