At Fri, 9 Nov 2001 13:57:05 +0900,
Jos Backus <josb / cncdsl.com> wrote:
> 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?


Standard eregex.rb lacks nagate feature.

class Regexp
  class Not
    def initialize(re)
      @re = re
    end
    def ===(str)
      !(@re === str)
    end
  end
  def -@
    Not.new(self)
  end
end

p %w{aap noot mies}.grep(-/a/)	# => ["noot", "mies"]


Otherwise, you can get extended eregex.rb from
http://member.nifty.ne.jp/nokada/archive/reop.rb

Nobu Nakada