JJava示例拆分正则表达式


JJava示例拆分正则表达式

import java.util.regex.Pattern;



public class Main {

   public static void main(String a[]) {

      String s1 = "Learn how to use regular expression in Java programming. Here are most commonly used example";

      Pattern p1 = Pattern.compile("(use|Java|are|use)");

      String[] parts = p1.split(s1);



      for(String p:parts) {

         System.out.println(p);

      }

   }

}