Java 示例 Word 的最后一个索引2


Java 示例 Word 的最后一个索引2

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
   public static void main(String args[]) {
      String s1 = "Sairamkrishna Mammahe,codingdict india Pvt Ltd.";
      Pattern p1 = Pattern.compile("codingdict");

      Matcher m1 = p1.matcher(s1);
      m1.find();
      int nextIndex = m1.end();

      System.out.print("The last index is:");
      System.out.println(nextIndex);
   }
}