regex for converting formulas back to symbolic logic