Notes for using the string splite () method blog type: j2se
. The java. lang package contains the string. Split () method, and an array is returned.
I have used some of them in the application. I will summarize them for your reference only:
1. If ". ", must be written as follows: string. split ("\\. "), in this way, the correct separation is not allowed using string. split (". ");
2. If "|" is used as the separator, it must be written as follows: string. split ("\ |"), in order to correctly separate, cannot use string. split ("| ");
"." And "|" are escape characters and must be added "\\";
3. If a string contains multiple delimiters, you can use "|" as a hyphen, for example, "acount =? And UU =? Or n = ?", Use string. Split ("and | or") to separate all three ");
4. if the string is "A/B //", if "/" is used to separate the length of the array separated by this string from 2, instead of 5, the array stores a and b. He will remove the null strings.
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.