From: Marcelo Alvim Date: 2006-10-24T11:28:35+09:00 Subject: Re: How to remove empty element in an array On 10/23/06, Li Chen wrote: > Hi, > > I think this time it should work: regxp for the empty sapce is ^\d*$. > > irb(main):003:0> a=[1,2,'','', 'a','b'] > => [1, 2, "", "", "a", "b"] > irb(main):004:0> a.delete_if {|x| x=~/^\d*$/} > => [1, 2, "a", "b"] I'm sorry, isn't \d used for a digit? irb(main):006:0> a = [1, '', 'a', '2', '3456'] => [1, "", "a", "2", "3456"] irb(main):007:0> a.delete_if{|x| x =~ /^\d*$/} => [1, "a"] This one will delete any string that is made of numbers only. Cheers, Alvim.