正则表达式的Java示例模式


正则表达式的Java示例模式

import java.util.regex.Matcher;

import java.util.regex.Pattern;



public class Matc {

   public static void main(String args[]) {

      Pattern p = Pattern.compile("\\d");

      Matcher mat1 = p.matcher("9652018244");



      while (mat1.find()) {

         System.out.println("\t\t" + mat1.group());

      }

      mat1.reset();

      System.out.println("After done resetting the Matcher, it should be like this");



      while (mat1.find()) {

         System.out.println("\t\t" + mat1.group());

      }

   }

}