Java examples for Language Basics:String
Match String value for one or the other
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|[Ff]alse]"); System.out.println(result);//w ww. j av a 2 s.com } }