PHP is a simple example of determining whether the brackets in the expression match.
As follows:
<? Php/*** title: determines whether the brackets in the expression match * Description) (mismatched use of the Pressure stack and the out stack * @ author Mr Lv */function isValid ($ expstr) {$ temp = array (); for ($ I = 0; $ I <strlen ($ expstr); $ I ++) {$ ch = $ expstr [$ I]; switch ($ ch) {case '(': array_push ($ temp, '('); break; case ')': if (empty ($ temp) | array_pop ($ temp )! = '(') {Return "missing left parentheses (" ;}} return empty ($ temp) = true? "Expression match": "The Right parenthesis is missing)";} $ expstrA = "(1 + 3 (6*4)-(2 + 3 ))()("; $ expstrB = "(1 + 3 (6*4)-(2 + 3) ()"; $ expstrC = "(1 + 3 (6*4) -(2 + 3) "; echo isValid ($ expstrA); echo" <br> "; echo isValid ($ expstrB); echo" <br> "; echo isValid ($ expstrC) ;?>
Page Information:
The right parenthesis is missing (
The above is all the simple examples provided by the small Editor for you to determine whether the brackets in the expression match. I hope you can provide more support ~