How to split the string before the 2nd occurrence of a character in Java -
How to split the string before the 2nd occurrence of a character in Java -
i have:
1234 2345 3456 4567 when seek string.split(" ",2), get:
{1234} , {2345 3456 4567} but need:
{1234},{2345} i want first 2 elements. how implement in java? in advance. edit:this 1 line of huge dataset.
i assume need first 2 string, following:
string[] res = arrays.copyofrange(string.split(" "), 0, 2); java string function split
Comments
Post a Comment