If lists are large, something like
list1[[;; (Position[list1, Except[0 |0.| Null], 1][[-1, 1]])]]
should be quite a bit faster, e.g., a quick test on a 50K length list it is over 350X faster than the rule-based solution, and 4X faster than the Take
solution.
If the list is "front-loaded" with values (i.e., more wanted than not), using
list1[[;; -Position[Reverse@list1, Except[List | 0 | 0. | Null], 1, 1][[1, 1]]]]
is thousands and hundreds of times faster than rule-based/take posted respectively.
If the lists are precisely the format in your example (desired, chunk of zeroes, chunk of nulls)
Flatten@Split[list1][[;; -3]]
is short, sweet, and very fast.
ImageCrop/ImageTrim
,StringTrim
but noListTrim
:/ :) $\endgroup$