import java.util.regex.Matcher; import java.util.regex.Pattern; public class MatcherGroupExample { public static void main(String args[]) { test(); } public static void test() { Pattern p = Pattern.compile("Bond"); String candidateString = "My name is Bond. James Bond."; Matcher matcher = p.matcher(candidateString); matcher.find(); System.out.println(matcher.group()); } }