Tags: differentiate nbsp expression analysis span character androi and;;Split () split string1. Distinctions in different environments
Java: The split string cannot be written as split ("$")//$ as the character to be split
Android: Split string needs to be combined with brackets split ("[$]")//$ for the character to be split
1 String str = "ABC|DFG"; 2 3 string All=str.split ("|") ); 4 5 System.out.println (all); 6 7 result for a
| In the regular expression is a special symbol (".", "|", "^") that has been used.
So want to use | , it must be escaped with \, and in the Java string, \ is a special symbol that has already been used, and it needs to be escaped using \.
Therefore, the following should be: string All=str.split ("\\|") ;
Android--split () Split string special usage