Java String match one or the other
public class Main { public static void main(String[] args) { String str = "False"; // This will test for one or the other boolean result = str.matches("[Tt]rue|[Ff]alse"); System.out.println(result); //from w ww.j a v a 2 s. c o m str = "false"; // This will test for one or the other result = str.matches("[Tt]rue|[Ff]alse"); System.out.println(result); } }