public static void main(String[] args) {
Pattern p = Pattern.compile("[A-Z]*");
Matcher matcher = p.matcher("CSE");
System.out.println(matcher.group());
}
why is the obove code raising an java.lang.IllegalStateException ? How can i match any number of capital letters?
You need to call
Matcher.find()to initiate the regex matching process.