String.split2()

Signature

String[] split2(String str, String regex, int limit)

Domain

action, condition

Description

Splits this string around matches of the given regular expression. The limit parameter controls the number of times the pattern is applied and therefore affects the length of the resulting array.

Parameters

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

Returns

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

Example


String[] result = String.split2("This,is,a,test",",",-1);

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


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

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