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






Matcher: start()

/*
 * Output:
java found at index 4
 * */

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("www.java2s.com 1 2 3 j a v a 2 s.c o m");

    while (mat.find()) {
      System.out.println("java found at index " + mat.start());
    }
  }
}

           
       








Related examples in the same category

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