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