From: OZAWA -Crouton- Sakuro Date: 2001-11-09T14:21:23+09:00 Subject: [ruby-talk:24738] Re: Negate grep pattern match? At Fri, 9 Nov 2001 13:57:05 +0900, Jos Backus wrote: > p a.grep(/a/) grep(pat) and grep(pat) block should be considered to be shortcuts for select{|item| pat==item } and select{|item| if pat==item then block(item); true; else false; end } respectively. > 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? If you are only to select items with 'grep', try 'reject' for negative selection. p a.reject{|x| /a/ =~ x} -- OZAWA -Crouton- Sakuro E-Mail: mailto:crouton@weatherlight.org Web: http://www.weatherlight.org/~crouton/ PGP: C98F 74E0 AEEB 4578 1DFC F650 3BE0 9627 11FC C9F5 VERBA VOLANT, SCRIPTA MANENT