Hi -- On Wed, 4 Oct 2006, Ken Collins wrote: > > I sure could... > > The hash is going to be real small. It would at most only have 3 or 4 keys. > The one I want has a prefix of an arbitrary string with any amount of number > after it. I need to know if this key is present so that I can run a > conditional block of code. It would be a bonus to get some match data back on > that last series of digits in the regexp. > > I would like to use something like this: > > def foobar > if hash.has_key?(/^foo_\d+$/) > ... > end > end I'm having trouble following this thread, because some message bodies aren't appearing -- but the basic answer is: /.../ is itself a potential hash key (since keys can be any object), so you have to do something other than just hand it off to has_key? if you want to search for a string key that matches it. David -- David A. Black | dblack / wobblini.net Author of "Ruby for Rails" [1] | Ruby/Rails training & consultancy [3] DABlog (DAB's Weblog) [2] | Co-director, Ruby Central, Inc. [4] [1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com [2] http://dablog.rubypal.com | [4] http://www.rubycentral.org