Use split method to split a string based on delimiters that match a regular expression - Java Regular Expressions

Java examples for Regular Expressions:Pattern

Introduction

A string is split into words marked by colons, semicolons, vertical bars, or tab characters.

Demo Code

public class Main {
  public static void main(String[] args) {
    String s = "One:Two;Three|Four\tFive";
    String regex = "[:;|\\t]";
    String strings[] = s.split(regex);
    for (String word : strings)
      System.out.println(word);//from w w w  . ja va 2s  . c  om
  }

}

Related Tutorials