title: Find mathematical operators in Java String?
body: <p>I want to be able to tell whether a string is a mathematical expression or not.
  The true nature of my problem is to find symbols that do not match with any of these: *, /, +, -, (, ), 0-9 in any given string.</p>
  
  <pre><code>if (Pattern.compile("[a-z]").matcher(inputExpression).find()) {
          return ErrorType.ALPHABETIC_SYMBOL;
      } else if (!inputExpression.matches("[-+*/()]") || !inputExpression.matches("[0-9]")) {
          return ErrorType.UNKNOWN_SYMBOL;
      }
  </code></pre>
  
  <p>What am I doing wrong? The program works if I remove the second if-statement and expect to find alphabetic symbols in my string.</p>
  
  <p>I tried to do the following: Change the matches method to .find() to find if the pattern is there as follows.</p>
  
  <pre><code>if (Pattern.compile("[a-z]").matcher(inputEquation).find()) {
          return ErrorType.ALPHABETIC_SYMBOL;
      } else if (!Pattern.compile("[-*+/]").matcher(inputEquation).find() &amp;&amp; !Pattern.compile("[0-9]").matcher(inputEquation).find()) {
          return ErrorType.UNKNOWN_SYMBOL;
      }
  </code></pre>
  
  <p>The code is still not working. I'm having logical errors.</p>