You can use a regular expression which specifies a class or group of characters in Scanner. : Scanner « Utility Classes « SCJP






import java.util.Scanner;

public class MainClass {
  public static void main(String[] argv) {

    String scanMe = "abcdefghijkl";
    String delim = "[aeoiu]";
    Scanner scanner = new Scanner(scanMe);
    scanner.useDelimiter(delim);
    while (scanner.hasNext())
      System.out.println(scanner.next());

  }
}
bcd
fgh
jkl








8.23.Scanner
8.23.1.Scanning Text
8.23.2.You can use a regular expression which specifies a class or group of characters in Scanner.
8.23.3.Tokenizing with Scanner