The use of split for Java functions

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.