From: "Shannon Fang" <xrfang / hotmail.com> > Hi > > In ruby, I can use the following to match a regexp: > > if string=~/pattern/ then ... > > However, the following does not work, > > if string!~/pattern/ then... > > I'll have to write > > if !(string=~/pattern/) then... > > Any suggestion? > > Shannon Funny that. My copy of "Ruby in a Nutshell" says that '!~' is an operator method, so I'm surprised that it's not defined for String. I had no luck defining it myself either. My suggestion is: unless string =~ /pattern/ then ... Gavin