I am using split() to gather values between periods in a String. If the user enters trailing periods, then split() does not return those periods as empty strings, but drops them:
String[] parts = "a.b.c...d...e".split("\\.");
for ( int i = 0; i < parts.length; i++ )
System.out.println("" + i + ": '" + parts[i] + "'" );
0: 'a'
1: 'b'
2: 'c'
3: ''
4: ''
5: 'd'
6: ''
7: ''
8: 'e'
Removing the last 'e':
String[] parts = "a.b.c...d...".split("\\.");
for ( int i = 0; i < parts.length; i++ )
System.out.println("" + i + ": '" + parts[i] + "'" );
0: 'a'
1: 'b'
2: 'c'
3: ''
4: ''
5: 'd'
What happened to parts 6 and 7? It seems that split() simply dropped them. Yet they are there in the String. Should not split() return parts 6 and 7 as empty strings?