jq
中的以下两个表达式之间有什么区别吗?表达1
match("prefix.*if you do";"gmi")
表达2
match(["prefix.*if you do","gmi"])
发现
{
"caveats": "The command has been installed with the prefix \"g\".\nIf you do not want the prefix, install using the \"with-default-names\"\noption.\n"
}
i
)标志或多行标记(m
)将导致匹配失败。[regex,flags]
或regex;flags
按照手册的说法工作:
The jq regex filters are defined so that they can be used using one of
these patterns:
STRING | FILTER( REGEX )
STRING | FILTER( REGEX; FLAGS )
STRING | FILTER( [REGEX] )
STRING | FILTER( [REGEX, FLAGS] )
;
和,
会导致意想不到的结果。从技术上讲,一切都表现得如预期。
但是由于我的例子简单,这些结果是否是间接的?
特别:
曾经有一段时间jq不支持多个arity功能。我相信你描述的二元性是那些日子的遗产。任何差异都是值得报道的错误。
(也许有些人养成了输入[x,y]
而不是x;y
而更喜欢前者的习惯?)