I would like to convert a String containing multiple numbers so that all those numbers become Integers. That is, I have:
"1,2,3,4,5,6,7,8,9,0" # String
" 1, 2, 3, 4, 5 , 6 ,7 ,8 ,9 , 0" # String (spaces are important)
and I would like to have:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 0] # Array
But there is more. If I have:
"1,2,3,4,5,a,b,c,d,e" # String
" 1, 2 , 3 , 4 , 5 , a, b,c , d , e" # String (spaces are important)
I would like to have (value that are not numbers are removed):
[1 , 2 , 3 , 4, 5] # Array
1 Answer