From: Judson Lester Date: 2007-12-14T05:06:47+09:00 Subject: Re: Regexp Matching Not Blank And Not A Specific Word? ------=_Part_42951_24297466.1197576411916 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Dec 13, 2007 11:09 AM, Phrogz wrote: > irb(main):006:0> tests = [ "", "dog", "cat", "doggone it" ] > => ["", "dog", "cat", "doggone it"] > > irb(main):007:0> tests.each do |str| > irb(main):008:1* hit = (str =~ /^(?!dog).+$|^dog.+$/) > irb(main):009:1> puts "#{str.inspect} => #{hit.inspect}" > irb(main):010:1> end > "" => nil > "dog" => nil > "cat" => 0 > "doggone it" => 0 Just to shill for a moment: I was doing that kind of irb stuff so often for regexps in Ruby, I wrote this: http://rubyforge.org/projects/regexpbench/ http://regexpbench.rubyforge.org/ Hope it's useful. Judson -- Your subnet is currently 169.254.0.0/16. You are likely to be eaten by a grue. ------=_Part_42951_24297466.1197576411916--