In message "[ruby-talk:24736] Negate grep pattern match?"
on Fri, 9 Nov 2001 13:57:05 +0900,
Jos Backus <josb / cncdsl.com> writes:
> Now how do I retrieve those array elements that do not match /a/? In Perl one
> can say @a = grep(!/a/, qw(aap noot mies)); does Ruby have a similar shortcut?
Enumerable#grep doesn't have such shortcut. Use find_all:
a = %w{aap noot mies}
p a.find_all{|x| /a/ !~ x} #=> ["noot", "mies"]
-- Gotoken