Detailed explanation of special usage cases of split() string segmentation in Android
Split() split string
1. Differentiation under different environments
Java: split string cannot be written as split ("$") / / $as the character to be split
Android: split ("[$]") / / $is the character to be split
2. Special usage -- when split() splits a string and encounters a special symbol
case analysis
The result is a
Cause analysis
|In regular expressions, it is a special symbol that has been used (".", "|", "^" and other characters). Therefore, if you want to use |, you must use \ to escape. In Java strings, \ is also a special symbol that has been used, and you also need to use \ to escape.
So it should be: String [] all = str.split ("\ \ |);
The above is the special usage of split() string segmentation in Android introduced by Xiaobian. I hope it will help you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!