title: Check numeric expression (linear) is valid or not?
body: <p>There are many ways to check string valid or not using regex expression and using match/test match accordingly.
  I am looking to check whether the expression containing alphabets(a-b), operators (+,-,/,*), only special characters like (')','(') and numerics (0-9) is valid or not</p>
  
  <p>I have already tried for traditional methods pushing when the character is '(' and popping when ')' and checking the balanced parenthesis or not.
  Code almost works for even operators but there are some cases where I am lacking behind.
  The code provided might be right to some extent.</p>
  
  <pre><code>                      checkBalancedString(text){
                          let format = /[A-Za-z0-9]/;
                          let expression = /[+-\/*]/
                          if(text.length &lt;=2){
                              if(format.test(text[0])){
                              return true;
                              }
                              return false;
                           }
                          for(let i=0;i&lt;text.length;i++){
                          let stringcheck=[]
                          if(text[i]== '('){
                              stringcheck.push(text[i])
                          }
  
                          switch(text[i]){
                              case ')':
                              if(!stringcheck.length){
                                  return false;
                              }
                              stringcheck.pop();
                              break;
                          }
                          let checkalphaformat = format.test(text[i]);
                          if(checkalphaformat){
                          let nextChar =  format.test(text[i+1]);
                          let nexttonextChar = expression.test(text[i+2])
                              if(nextChar || nexttonextChar){
                              return false
                              }
                          }else{
                              let nextChar = format.test(text[i+1]);
                              if(!nextChar){
                              return false;
                              }
                              if(text[i+2]){
                              let nextChar = format.test(text[i+2])
                              if(!nextChar){
                                  return false;
                              }
                              }
                          }
  
                          if(!stringcheck.length){
                              return true;
                          }
                          }
  
                          }
  </code></pre>
  
  <p>In short string should return valid where expression like:
  (a+b), a+b, a/9, b*5 , (e-6*(d+e)), (a+b)/(c-d)
  and expression like:
  +, - ,-a,+a-, (a+, (a+v, e*)</p>
  
  <p>The expression should be complete when every character is followed by the operator or parenthesis
  either operator is followed by only characters
  and parenthesis is followed by the only character.
  There should be no operator together from the present index (front and behind)and no two characters together</p>