Ruby's regexp: Is there no opposite of =~?

Hi,

Searching through “Programming Ruby” I found the Perl-like “=~” for
matching strings against regexps but I cannot find the opposite
"dont match" operator ( “!~” in Perl ).

Is there any aequivalent ?

Kind regards,
Meino

Yes… it’s !~ :slight_smile:

(Actually, a !~ b is the same as !(a =~ b), i.e. there is no !~ method as
such; in the same way that a += b is expanded to a = a + b and so there is
no += operator as such)

···

On Sun, Aug 17, 2003 at 07:46:33PM +0900, Meino Christian Cramer wrote:

Hi,

Searching through “Programming Ruby” I found the Perl-like “=~” for
matching strings against regexps but I cannot find the opposite
“dont match” operator ( “!~” in Perl ).

Is there any aequivalent ?

batsman@tux-chan:/tmp$ ruby
p “aabbaasdff” !~ /bb/
^D
false

···

On Sun, Aug 17, 2003 at 07:46:33PM +0900, Meino Christian Cramer wrote:

Hi,

Searching through “Programming Ruby” I found the Perl-like “=~” for
matching strings against regexps but I cannot find the opposite
“dont match” operator ( “!~” in Perl ).

Is there any aequivalent ?


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

Those who don’t understand Linux are doomed to reinvent it, poorly.
– unidentified source