From: Yasuo Saito Date: 2002-06-28T23:33:16+09:00 Subject: Re: Negation of regular expression > > If any regular expression r is given, > > how can I write the negation of r in Ruby? > > > > I want something like operator ! in Perl -- eg. grep(!/foo/, @bar) > > --, or option -v of egrep -- eg. egrep -v foo file --. > > @bar.reject { |ea| ea ~ /foo/ } Thank you for your answer. But, how should I do in the following case? class A def initialize(string) @string = string end def execute(regexp) if (@string =~ regexp) then # ... else # ... end end end class B def execute(a, regexp) a.execute(!regexp) # ERROR... How should I do? end end B.new.execute(A.new("foo"), /bar/) -- Y.Saito