import re


def jsonp_is_valid(funcname):
    """Returns whether the jsonp function name is valid

    :arg funcname: the name of the jsonp function

    :returns: True or False

    """
    func_regex = re.compile(
        r"""
        ^[a-zA-Z_\$]
        [a-zA-Z0-9_\$]*
        (\[[a-zA-Z0-9_\$]*\])*
        (\.[a-zA-Z0-9_\$]+
            (\[[a-zA-Z0-9_\$]*\])*
        )*$
    """,
        re.VERBOSE,
    )
    return bool(func_regex.match(funcname))