Hi,
Which command can use for deleting empty space for the below list?
S1 = {"5", "10", "7", "", "", "", "", ""}
Thank for your help.
Why not simply:
DeleteCases[S1,""]
?
DeleteCases[S1 /. "" -> x, x] (* {"5", "10", "7"} *)
A more general approach if you only want to select the stings that actually are a number.
Select[S1, StringMatchQ[#, NumberString] &]
You right Sander. I appreciate your help.
I know it's not the same thing as deleting, but with the Drop command also arrives at the same result.
S1 = {"5", "10", "7", "", "", "", "", ""}; Drop[S1, {-5, -1}] (* {5,10,7} *)
Sander is correct. You typed what he posted incorrectly. You want to delete the empty strings so you must enter , not ,,
Regards
Hi Sander,
An interesting solution! Many thanks, Mariusz.