From: Glenn Jackman Date: 2009-07-14T19:35:08+09:00 Subject: Re: a regex that does not contain comma At 2009-07-14 06:01AM, "Axel Schmalowsky" wrote: > I'm confused. Trying the regexp /^[^,]*$/ fails with the code below: > > #! /opt/csw/bin/ruby > > string = "Hello, world" > #regexp = /\w+(?>\s*(?=,))+/ > regexp = /^[^,]*$/ > > if string =~ regexp > puts "string contains a comma" > else > puts "string does not contain a comma" > end case string when /,/ then puts "#{string.inspect} contains a comma" when /^[^,]*$/ then puts "#{string.inspect} has no comma" end -- Glenn Jackman Write a wise saying and your name will live forever. -- Anonymous