String.split()

Signature

String[] split(String str, String regex)

Domain

action, condition

Description

Splits this string around matches of the given regular expression. Trailing empty strings are not included in the resulting array.

Parameters

NameTypeDescription
strString A String to be split.
regexString The delimiting regular expression.

Returns

TypeDescription
String[]The array of strings computed by splitting this string around matches of the given regular expression.

Example


String[] result = String.split("This,is,a,test", ",");

Result is:
result = {"This", "is", "a", "test" }


String[] result = String.split("This|is|a|test", "\\|");

Result is:
result = {"This", "is", "a", "test" }