Several characters that need to be escaped when splitting in Java
•
Java
String[] strs1=str1.split("\\|"); String[] strs2=str2.split("\\."); String[] strs3=str3.split("&"); String[] strs4=str4.split("\\*"); String[] strs5=str5.split("\\+"); Sy<a href="https://www.jb51.cc/tag/stem/" target="_blank" class="keywords">stem</a>.out.println("(1)----------------(符号:|)"); for(String s:strs1){ Sy<a href="https://www.jb51.cc/tag/stem/" target="_blank" class="keywords">stem</a>.out.println(s); } Sy<a href="https://www.jb51.cc/tag/stem/" target="_blank" class="keywords">stem</a>.out.println("(2)----------------(符号:.)"); for(String s:strs2){ Sy<a href="https://www.jb51.cc/tag/stem/" target="_blank" class="keywords">stem</a>.out.println(s); } Sy<a href="https://www.jb51.cc/tag/stem/" target="_blank" class="keywords">stem</a>.out.println("(3)----------------(符号:&)"); for(String s:strs3){ Sy<a href="https://www.jb51.cc/tag/stem/" target="_blank" class="keywords">stem</a>.out.println(s); } Sy<a href="https://www.jb51.cc/tag/stem/" target="_blank" class="keywords">stem</a>.out.println("(4)----------------(符号:*)"); for(String s:strs4){ Sy<a href="https://www.jb51.cc/tag/stem/" target="_blank" class="keywords">stem</a>.out.println(s); } Sy<a href="https://www.jb51.cc/tag/stem/" target="_blank" class="keywords">stem</a>.out.println("(5)----------------(符号:+)"); for(String s:strs5){ Sy<a href="https://www.jb51.cc/tag/stem/" target="_blank" class="keywords">stem</a>.out.println(s); } }
}
输出结果:
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码