我有两个正则表达式:
[a-c] : any character from a-c
[a-z] : any character from a-z
和一个测试:
public static void main(String[] args) {
String s = "abcde";
String[] arr1 = s.split("[a-c]");
String[] arr2 = s.split("[a-z]");
System.out.println(arr1.length); //prints 4 : "", "", "", "de"
System.out.println(arr2.length); //prints 0
}
为什么第二次分裂会这样?我希望得到一个带有 6 个空字符串 "" 结果的结果。