Java Tutorial/Regular Expressions/Pattern Split — различия между версиями
| Admin (обсуждение | вклад) м (1 версия) | Admin (обсуждение | вклад)  м (1 версия) | 
| (нет различий) | |
Текущая версия на 15:19, 31 мая 2010
Demonstrates usage of the Pattern split method
import java.util.regex.Pattern;
public class MainClass {
  public static void main(String args[]) {
    String statement = "a b c d e f g h i j k l";
    String splitPattern = "e|c|a|a|(a b d e)|(b c e)";
    Pattern p = Pattern.rupile(splitPattern);
    String[] tokens = p.split(statement);
    for (int i = 0; i < tokens.length; i++) {
      System.out.println(tokens[i]);
    }
  }
}
   
