如何排除kdb中字符串中的某些记录?

How to exclude some records in string in kdb?

我想从 table.

中排除一些记录
a:("abc*";"eeee*")
tab:([]cola:("abcdef";"bcdefgh";"tttttt");colb:`a`b`c)

如果我只想要某些记录,它会起作用: 例如

raze {select from tab where cola like x } each a

输出:

cola     colb
-------------
"abcdef" a

现在我想通过运行以下命令排除上面的记录

raze {select from tab where not cola like x } each a

但是 returns

cola      colb
--------------
"bcdefgh" b
"tttttt"  c
"abcdef"  a
"bcdefgh" b
"tttttt"  c

我想 return 这个:

 cola      colb
--------------
"bcdefgh" b
"tttttt"  c

这个有用吗?

q)select from tab where not any cola like/: a
cola      colb
--------------
"bcdefgh" b   
"tttttt"  c   

编辑:为什么我们需要一个 any?

如果用列名索引到 table 中以将列作为数组获取,则更容易看到:

q)tab[`cola]
"abcdef"
"bcdefgh"
"tttttt"
q)tab[`cola] like/: a
100b
000b
q)any tab[`cola] like/: a
100b
q)not any tab[`cola] like/: a
011b

当您对多个字符串和多个正则表达式使用 like 时,您将获得每个字符串的数组(数组的大小是正则表达式的数量)。我们想看看我们的字符串是否匹配任何正则表达式,如果匹配则排除它们。