1

I have 3 keys id=foo1, id=foo10. id=foo100. I would like to match only keys which ends with id=foo1 or contains id=foo1

So the first query should return a single result and the last query should return 3 results.

4

2 に答える 2

3

何かのようなもの

r=Redis.new
r.keys("*foo1")
r.keys("*foo1*")
于 2013-04-24T08:56:29.330 に答える
0
keys = ["id=foo1","id=foo10","id=foo100"]
p keys.select {|x| x.include? 'id=foo1'}
#=> ["id=foo1", "id=foo10", "id=foo100"]
p keys.select {|x| x.end_with? 'id=foo1'}
#=> ["id=foo1"]
于 2013-04-24T08:50:40.430 に答える