recently writing a course design, it was necessary to sort the input comma-separated integer string into an array, so I found this function that seemed to me to be super-divine:
Stringobj.split (String regex,int limit)
where stringobj represents a string object that needs to be split, and the object will not be changed after using the split method; The parameter regex is a cut character, which can be a string or a regular expression that identifies whether a split string is using one or more characters, the parameter limit is optional, and its value is used to limit the number of elements in the returned array.
If the separator is "." or "|" , you need to precede the delimiter with "\ \", that is, call form: Stringobj.split ("\ \") or Stringobj.split ("\\|").
e.g
String St = "1,2,3,4,5,6,7,8,9";
string[] strary = St . Split (",");
The elements stored in the strary array are: 1,2,3,4,5,6,7,8,9
This article is from the "Guardian" blog, please be sure to keep this source http://acevi.blog.51cto.com/13261784/1981800
Use of Split for Java functions