Pattern pattern = Pattern.compile("(?i).*"); // using Pattern Pattern mypattern = Pattern.compile(MYREGEX, Pattern.CASE_INSENSITIVE); // or str.matches("(?i).*"); // or directly