On Wednesday 21 August 2002 11:12 am, Slava Potsepnia wrote: > Hi All! > > I would like to know if it's possible to negate regexps in > case-when-then-else-end. I.g. > > line ="I need to know" > case line > when <not>? <!>? /^I need .*/ > puts "right" > end > > Best regards, > Slava Potsepnia I may be all wrong, but I thought case was equivalent to: if line === something do_something elseif line === something_else do_something_else else do_default end If this is so, that "===" is implied, then the "when" cannot contain just the regex. This is klunky but works: def nomatch(str, regex) if str !~ regex str else nil end end line = "I nyeed to know" regex = %r{^I need.*} case line when regex puts "a match" when nomatch(line, regex) puts "no match" end