简体   繁体   English

Redis keys命令不适用于某些字符

[英]redis keys command does not work with certain characters

I can't figure out why certain redis KEYS commands are behaving like this. 我不知道为什么某些redis KEYS命令的行为是这样的。

This returns all keys starting with "string:term": 这将返回以“ string:term”开头的所有键:

keys "tag:[term]*"

When I put a .js in (even escaping it), it returns all keys that contain .js - the second part of the "regex" I'm trying to include: 当我放入一个.js (甚至转义它)时,它返回所有包含.js键-我试图包括的“ regex”的第二部分:

keys "tag:[term\.com]*"; 
keys "tag:[term.com]*";

For some background, the documentation implies regular expressions within square brackets: 对于某些背景, 文档暗含在方括号内的正则表达式:

h[ae]llo matches hello and hallo, but not hillo h [ae] llo匹配hello和hallo,但不匹配hillo

The KEYS command does not use regular expressions but glob-style pattern matching (compatible with the basic Unix shells). KEYS命令不使用正则表达式,而是使用glob样式的模式匹配 (与基本的Unix shell兼容)。

keys "tag:[term]*"

does return many more keys than "all keys starting with tag:term". 确实比“以tag:term开头的所有键”返回的键更多。 It returns all keys starting with tag: plus a single character among [ 't', 'e', 'r', 'm' ]. 它返回以tag开头的所有键:以及['t','e','r','m']之间的单个字符。

To return all keys starting with tag:term, you need to use "tag:term*" 要返回以tag:term开头的所有键,您需要使用“ tag:term *”

The documentation does not implies regular expressions, just glob-style patterns. 该文档并不暗示正则表达式,而只是隐含样式样式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM