js -- 单个字符分割
let a= "我是,一段字,符串";
let b = a.split(",");
console.log(b); // array(3)["我是","一段字","符串"]
多字符分割
let a= "我/是,一段/字,符串";
let b = a.split(/[,/]/);
console.log(b); // array(5)["我","是","一段","字","符串"]
java 单字符 *** 注意点 (.|)均为转义字符 需要用到 \\ (如) \\. \\|
String a= "我是,一段字,符串";
String b[] = a.split(",");
System.out.println(b); // array(3)["我是","一段字","符串"]
多字符分割
let a= "我/是,一段/字,符串";
let b = a.split(",|/");
System.out.println(b); // array(5)["我","是","一段","字","符串"]