Do I really need space to get three elements after split? Or could someone explain why is that so? (note: code in ruby, not sure how it is in different languages)
test1="2011112512215| | "
test2="2011112512215||"
puts test1.split("|").length # =3
puts test2.split("|").length # =1
No, String#split takes a second parameter where you can specify a limit for the number of splits that will occure.
Passing a negative value will make the function not remove trailing elements of length
0.