http://deejay.iteye.com/blog/1327491
- function checkBracket(algorithms){
- var bracket = [];
- var algorithms= algorithms ||‘‘;
- for(var i=0; i<algorithms.length; i++){
- if(algorithms.charAt(i)=="("){
- bracket.push(‘(‘);
- }
- if(algorithms.charAt(i)==")"){
- if(bracket.length){
- bracket.pop();
- }else{
- alert(‘公式括号不配对,缺少左括号!‘)
- return false;
- }
- }
- }
- if(bracket.length){
- alert(‘公式括号不配对,缺少右括号!‘)
- return false;
- }
- return true;
- }
时间: 2024-11-01 19:12:44