From: Lars Haugseth Date: 2012-09-07T16:43:43+09:00 Subject: Re: Not Match? On 09/06/2012 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? Just negate the match condition with an exclamation mark: if !xxx.match(/found/) puts "No match" end -- Lars Haugseth