Java split方法一个或多个特殊字符分割

public static void main(String[] args) {
String s = "ab|cd|ef";

//String s = "ab;cd,ef";

//String[] split = s.split(";|,");

String[] split = s.split("\\|");
// System.out.println(split[0]);
for(int i = 0; i < split.length; ++i ) {
System.out.println(split[i]);
}
}

posted on 2023-05-17 10:36  多言  阅读(515)  评论(0编辑  收藏  举报

导航