Java示例拆分正则表达式


Java示例拆分正则表达式

import java.util.regex.Pattern;



public class PatternSplitExample {

   public static void main(String args[]) {

      Pattern p = Pattern.compile(" ");

      String tmp = "this is the Java example";

      String[] tokens = p.split(tmp);



      for (int i = 0; i < tokens.length; i++) {

         System.out.println(tokens[i]);

      }

   }

}