How to write an if statement that checks if input has any letters

I need a regex that gives me true when a letter exists in the input. I have tried if (formula.contains("[a-zA-Z]+") == true), but this does not seem to work.

Hi! I figured it out! formula.matches(".*[a-zA-Z].*") this worked!

Answer

You’ll need String#matches(regex) for this and a correct of course

if (formula.matches(".*[a-zA-Z].*")) {
    // do stuff
}

The regular expression hereabove means

.             Any character
 *            Zero or multiple times
  [a-zA-Z]    One letter in ranges a-z or A-Z
          .   Any character
           *  Zero or multiple times