The function by Mathematica to expand a formulation with ANDS, ORS, NOT, XOR, and others, is LogicalExpand
, let see an example:
LogicalExpand[ p && (q || x)]
(p && q) || (p && x)
I want to make the same thing but with strings, and these strings can be regular expression (it's contains parenthesis in some cases). I mean the form of the strings. Let set a test case.
expr = "(?i)god && (evil || salvation(.) )"
MyLogicalExpand[ expr ]
And the result should be:
"(?i)god && evil || (?i)god && salvation(.)"
Notice that result don't group the atomic expression with parenthesis and the regular expression are the same.
I don't know which way I should take. It's a parser problem, and the regular expression make it more complex, some space after o before inside atomic expressions could be appear.
How do you program MyLogicalExpand
method ?