split 中文 java_Java String[] split() 方法
public class Test {
public static void main(String args[]) {
String str = new String("Welcome-to-Itizixishi");
System.out.println("- 分隔符返回值 :" );
for (String retval: str.split("-")){
System.out.println(retval);
}
System.out.println("");
System.out.println("- 分隔符設(shè)置分割份數(shù)返回值 :" );
for (String retval: str.split("-", 2)){
System.out.println(retval);
}
System.out.println("");
String str2 = new String("www.itzixihsi.com");
System.out.println("轉(zhuǎn)義字符返回值 :" );
for (String retval: str2.split("\\.", 3)){
System.out.println(retval);
}
System.out.println("");
String str3 = new String("acount=? and uu =? or n=?");
System.out.println("多個(gè)分隔符返回值 :" );
for (String retval: str3.split("and|or")){
System.out.println(retval);
}
}
}
總結(jié)
以上是生活随笔為你收集整理的split 中文 java_Java String[] split() 方法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mybatis-plus主键配置、全局配
- 下一篇: swat模型_文献分享——欧洲大陆尺度水