import regex
r = """(?x)
{
    (\\w+)
    :
    (
        (?:
            [^{}]
            |
            (?R)
        )+
    )
}
"""
z = '{1:abc}{2:{3:{4:foo}}}{5:bar}'
print(dict(regex.findall(r, z)))
splitting a braces grouped string in python