My code is:
String s = "1;;;; 23;;";
System.out.println(s.split(";").length);
and gives as output 5
.
The source code of split
is:
public String[] split(String regex) {
return split(regex, 0);
}
and the documentation says:
This method works as if by invoking the two-argument split(java.lang.String,int) method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array.
The string "boo:and:foo", for example, yields the following results with these expressions:
Regex Result : { "boo", "and", "foo" } o { "b", "", ":and:f" }
If I print the strings I have:
1
23
Shouldn't I get from this 1;;;; 23;;
something like {"1", "", "", "", " 23", ""}
?