Skip to content

like

Whether text matches a pattern

x like y    like[x;y]

Where

  • x is a symbol or string
  • y is a pattern as a string

returns a boolean: whether x matches the pattern of y.

q)`quick like "qu?ck"
1b
q)`brown like "br[ao]wn"
1b
q)`quickly like "quick*"
1b

Absent pattern characters in y, like is equivalent to {y~string x}.

q)`quick like "quick"
1b
q)`quick like "quickish"
0b

Implicit iteration

like applies to lists of strings or symbols; and to dictionaries with them as values.

q)`brawn`brown like "br[^o]wn"
10b

q)(`a`b`c!`quick`brown`fox)like "brown"
a| 0
b| 1
c| 0

ss, ssr,
Regular expressions in q, Strings
Using regular expressions