Match String with upper or lower case - Java Language Basics

Java examples for Language Basics:String

Description

Match String with upper or lower case

Demo Code

public class Main {
  public static void main(String[] args) throws Exception {
    String str = "true";

    // This will 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 .jav a2  s. com
  }
}

Result


Related Tutorials