My code is:
String s = "1;;;; 23;;";
System.out.println(s.split(";").length);
and gives as a conclusion 5. Source Code split:
public String[] split(String regex) {
return split(regex, 0);
}
and the documentation says:
This method works as if you were calling two split arguments (java.lang.String, int) with the given expression and a limit argument of zero. Therefore, trailing empty lines are not included in the resulting array.
For example, the string "boo: and: foo" gives the following results: with these expressions:
Regex Result
: { "boo", "and", "foo" }
o { "b", "", ":and:f" }
If I print the lines that I have:
1
23
Can I get 1;;;; 23;;something like this from this {"1", "", "", "", " 23", ""}?
source
share