Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 3 个键 id=foo1,id=foo10。id=foo100。我只想匹配以 id=foo1 结尾或包含 id=foo1 的键
所以第一个查询应该返回一个结果,最后一个查询应该返回 3 个结果。
就像是
r=Redis.new r.keys("*foo1") r.keys("*foo1*")
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"]