[Java] split ( ".") Failed solutions

String str4 = "115.157.200.135";
		String splitedArray [] = str4.split("\\.");
		System.out.println("SplitedArray.length = "+splitedArray.length);
		for (int i = 0 ; i < splitedArray.length ; i++) {
			System.out.print(splitedArray[i]+"\t");
		}

Output:

Cause Analysis:

Str.split parameter () is a regular expression, regular expression meta-characters must be escaped escaped symbols

Here, in the regular expression itself is not represented, but. "" '.':

. Matches any single character except "\ n" is. To match include '\ n', including any character, like the use of '[. \ N]' mode.

Guess you like

Origin blog.csdn.net/chenhanxuan1999/article/details/91399823