Tokenizing with String.split() : Regex « Utility Classes « SCJP






public class MainClass {
  public static void main(String[] args) {
    String[] tokens = args[0].split(args[1]);
    System.out.println("count " + tokens.length);
    for (String s : tokens)
      System.out.println(">" + s + "<");
  }
}








8.24.Regex
8.24.1.. Matches any character
8.24.2.\d Matches any digit ("0" - "9")
8.24.3.\s Matches any whitespace character, such as space, tab, or newline
8.24.4.\w Matches any letter ("a" - "z" or "A" - "Z") or digit
8.24.5.Using escape sequence in regular expression.
8.24.6.* Matches zero or more occurrences of the preceding pattern
8.24.7.+ Matches one or more occurrences of the preceding pattern
8.24.8.? Matches zero or one occurrences of the preceding pattern
8.24.9.Flags for regex
8.24.10.A small program that uses a console to support testing another class
8.24.11.Tokenizing with String.split()