From: "Jesús Gabriel y Galán" Date: 2012-09-07T16:01:22+09:00 Subject: Re: Not Match? On Thu, Sep 6, 2012 at 11:42 PM, Wayne Brisette wrote: > Either I'm missing it, or I can't be as clever as I want to be. ;) > > > I have some data that I'm evaluating I want to do the opposite of what .match > does. That is something like this: > > puts "No Match" if xxx.match(/found/) > > That's the easy part, but I actually want to take action if a match isn't found. > While I can do something like: > > if xxx.match(/found/) > else > puts "No Match" > end > > I was hoping not to do that. Is there a more Ruby like way of doing this? Is > there a 'no match' method I'm overlooking in the docs? There's also !~, which is the opposite of != 1.9.2p290 :001 > "abc" !~ /\d+/ => true 1.9.2p290 :002 > "123" !~ /\d+/ => false Jesus.