From: Mark Probert Date: 2002-09-24T03:21:34+09:00 Subject: Re: another easy one... At 02:37 AM 9/24/2002 +0900, gminick wrote: >On Tue, Sep 24, 2002 at 01:09:45AM +0900, Mark Probert wrote: > > Say, ch is a character and I want to find if it > > exists in a regexp /A-Za-z0-9_/. How do I do it? > > > > irb> c.include?(/A-Za-z0-9_/) > > "TypeError: cannot convert Regexp into String" >Don't know if it is possible to use include? here, >but you can do this with "=~": > >c =~ /[A-Za-z0-9_]/ > >Returns 0 if true, nil if false. >HTH. That was my original thought: $ cat blah.rb c = "C" case c when c =~ /[A-Za-z0-9_]/ puts "yip!" else puts "nope..." end $ ruby !$ ruby blah.rb nope... $ ruby -v ruby 1.7.2 (2002-07-02) [i386-mswin32] -mark.