- string = re.sub(r'\band\b|,|&&|/\\|∧|∩', r' & ', string)
- string = re.sub(r'\bor\b|;|\|\||\\/|∨|∪', r' | ', string)
- string = re.sub(r'\bnot\b|!|¬', r' ~', string)
- tokens = re.split(r'(&|\||~)', string)
+ string = cls._RE_AND.sub(r' & ', string)
+ string = cls._RE_OR.sub(r' | ', string)
+ string = cls._RE_NOT.sub(r' ~', string)
+ # add implicit multiplication operators, e.g. '5x' -> '5*x'
+ string = cls._RE_NUM_VAR.sub(r'\1*\2', string)
+ # add parentheses to force precedence
+ tokens = cls._RE_OPERATORS.split(string)