Java正则表达式模式拆分示例


Java正则表达式模式拆分示例

package com.codingdict;



import java.util.regex.Pattern;



public class PatternDemo {

   private static String REGEX = ":";

   private static String INPUT = "boo:and:foo";



   public static void main(String[] args) {

      Pattern pattern = Pattern.compile(REGEX);



      String[] result = pattern.split(INPUT);

      for(String data:result){

         System.out.println(data);

      }

   }

}