String.split2()
Signature
String[] split2(String str, String regex, int limit)
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
Name | Type | Description |
str | String |
A String to be split. |
regex | String |
The delimiting regular expression. |
limit | the |
Result threshold. |
Returns
Type | Description |
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"}