Java String match both upper case and lower case

Description

Java String match both upper case and lower case

public class Main {

   public static void main(String[] args) {
      String str = "True";

      // test against both upper & lower case "T"...this will be TRUE
      boolean result = str.matches("[Tt]rue");

      System.out.println(result);

   }//from  w  w  w. ja  v  a 2 s  .  c  om

}



PreviousNext

Related