Marcelo Alvim
10/24/2006 2:29:00 AM
On 10/23/06, Li Chen <chen_li3@yahoo.com> 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.