Matcher: find()
/* * Output: Looking for Java in Java 2. subsequence found * */ import java.util.regex.Matcher; import java.util.regex.Pattern; public class MainClass { public static void main(String args[]) { Pattern pat = Pattern.compile("Java"); Matcher mat = pat.matcher("Java 2"); System.out.println("Looking for Java in Java 2."); if (mat.find()) System.out.println("subsequence found"); else System.out.println("No Match"); } }