I have an array that looks like this:
["lorem", "ipsum", "1734", "dolor", "1", "301", "et", "4102", "92"]
Is there a way to remove all the numbers in the array, even though they're stored as strings, so that I'd be left with this:
["lorem", "ipsum", "dolor", "et"]
Thanks for any hints.
Use a regexp pattern
s = ["lorem", "ipsum", "1734", "dolor", "1", "301", "et", "4102", "92"]
s.reject { |l| l =~ /\A\d+\z/ }
# => ["lorem", "ipsum", "dolor", "et"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With