K
Ken said:def foobar
unless params.reject{ |k, v| k !~ /^foo_\d+$/ }.empty?
...
end
end
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
MonkeeSage said:How about:
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.