find()は部分一致検索
lookingAtは先頭一致
matchesは完全一致
String s = "ABC1DEF";
Pattern p = Pattern.compile("[A-Z]{3}");
Matcher mc = p.matcher(s);
System.out.println(mc.find());
System.out.println(mc.group());
System.out.println(mc.find());
System.out.println(mc.group());
System.out.println(mc.find());
System.out.println("-----------------");
System.out.println(mc.lookingAt());
System.out.println(mc.group());
System.out.println(mc.lookingAt());
System.out.println(mc.group());
System.out.println("-----------------");
System.out.println(mc.matches());
mc = p.matcher("ABC");
System.out.println(mc.matches());
true
ABC
true
DEF
false
-----------------
true
ABC
true
ABC
-----------------
false
true