I need my students to be able to specifically enter parentheses in their equation and then validate that they entered it correctly.
I want to take it step by step
so I give them d^3 + (c^2 - 2) when d is 2/5 and c is -4
I want them to respond by typing in \left(\frac{2}{5}\right)^{3}\ +\ \left(\left(-4\right)^{2}\ -\ 2\right)
(2/5)^3 + ((-4)^2 - 2)
and check their pattern to see if it is correct. I have tried variations of the following:
pattern = p.sum(p.exponent(p.integer.allowParens,p.integer),p.difference(p.exponent(p.integer.allowParens,p.integer),p.integer).allowParens).allowParens
pattern.matches(this.latex)
AND
pattern = p.sum(p.exponent(p.integer,p.integer),p.difference(p.exponent(p.integer,p.integer),p.integer))
matches = pattern.allowNegativeTerms.allowParens.matches(this.latex)
AND other iterations, but none seem to be working