import re


def bnet2sympy(rule):
    """Converts a BNet string expression to a sympy string expression.

    Parameters
    ----------
    rule : str
        Boolean expression in BNET format.

    Returns
    -------
    str
        Expression in sympy format.

    """

    crule = re.sub("!","~",rule)
    crule = re.sub("[\b\(]1[\b\)]","(x | ~x)",crule)
    crule = re.sub("[\b\(]0[\b\)]","(x & ~x)",crule)
    crule = re.sub("True","(x | ~x)",crule)
    crule = re.sub("False","(x & ~x)",crule)

    return crule