From: "David A. Black" Date: 2009-07-14T21:54:06+09:00 Subject: Re: a regex that does not contain comma Hi -- On Tue, 14 Jul 2009, Glenn Jackman wrote: > case string > when /,/ then puts "#{string.inspect} contains a comma" > when /^[^,]*$/ then puts "#{string.inspect} has no comma" > end That second regex, on its own, won't tell you the whole story: string = <<-EOM Hi. I have, at a minimum, two commas. Bye. EOM p "Match!" if /^[^,]*$/.match(string) => Match! You'd want to use \A and \z, rather than ^ and $ (which delimit lines, rather than the whole string). But if you've already tested for /,/, then you should be able just to have an else clause in your case statement, to cover cases where /,/ didn't match. David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Now available: The Well-Grounded Rubyist (http://manning.com/black2) Training! Intro to Ruby, with Black & Kastner, September 14-17 (More info: http://rubyurl.com/vmzN)