Matcher: find() : Matcher « java.util.regex « Java by API






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");
  }
}

           
       








Related examples in the same category

1.Matcher: appendReplacement(StringBuffer sb,String replacement)
2.Matcher.appendTail(StringBuffer sb)
3.Matcher: group()
4.Matcher: group(int group)
5.Matcher: groupCount()
6.Matcher: lookingAt()
7.Matcher: matches()
8.Matcher: replaceAll(String text)
9.Matcher: start()