Java split () method

Source: Internet
Author: User

Java split () method


1. Method Introduction

(1) publicString[] Split (String regex) splits this String based on the matching regular expression.

(2) public String [] split (String regex, int limit) splits the String based on the matching regular expression.


2. Method example

/*** @ Title: Split. java * @ Package: com. you. data * @ Description: Java split () method * @ Author: youhaidong * @ date: 7:13:37, January 1, March 17, 2014 * @ Version V1.2.3 */package com. you. data;/*** @ Class Name: Split * @ Description: 1. split (String regex) * split the String based on the matching of the given regular expression ** 2. split (String regex, int limit) * split the String based on the matching given regular expression. * @ Author: You Haidong * @ date: 7:13:37, January 1, March 17, 2014 */public class Split {/*** @ Title: main * @ Type: Split * @ date: march 17, 2014 7:13:37 * @ Description: 1. public String [] split (String regex) * This method is used to call the split method with the given expression and the limit parameter 0. * Therefore, the resulting array does not contain trailing null strings. ** 2. public String [] split (String regex, int limit) * The array returned by this method contains the substring of this String, each substring is terminated by another substring * that matches the given expression, or by the end of the substring. The * substrings in the array are arranged in the order they appear in this string. If the expression does not match any part of the input *, the resulting array has only one element, that is, this string. * @ Param args */public static void main (String [] args) {/*** declare a String str1 */String str1 = "ui78, 8huh, jf87, uie8, ujkdf90, hu67ghj, 894ghk ";/*** declare the String array str2 */String [] str2 = str1.split (","); /*** traverse the string array */for (int I = 0; I
 
  
3. instance result

0th: ui78 1st: 8huh 2nd: jf87 3rd: uie8 4th: ujkdf90 5th: hu67ghj 6th: 894ghk 0th: ui78, 8huh, jf87, uie8, ujkdf90, hu67ghj, 894ghk 0th: ui78 1st: 8huh, jf87, uie8, ujkdf90, hu67ghj, 000000000th: ui78 1st: 8huh 2nd: jf87, uie8, ujkdf90, hu67ghj, 894ghk 0th: ui78 1st: 8huh 2nd: jf87 3rd: uie8, ujkdf90, hu67ghj, 894ghk 0th: ui78 1st: 8huh 2nd: jf87 3rd: uie8 4th: ujkdf90, hu67ghj, 894ghk 0th: ui78 1st: 8huh 2nd: jf87 3rd: uie8 4th: ujkdf90 5th: hu67ghj, 894ghk



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.