On Friday 28 June 2002 08:55 am, Yasuo Saito wrote:
> Hi.
>
> 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 --.

irb(main):043:0> x = 'abcd'
"abcd"
irb(main):044:0> x =~ /bc/
1
irb(main):045:0> x =~ /ef/
nil
irb(main):046:0> x !~ /bc/
false
irb(main):047:0> x !~ /ef/
true