Search code examples
regexmatchkdb

kdb: how to match complex strings


I have a table like this

t:([] c1:til 5;c2:("abcde";"cdefg";"ecbda";"bsdee";"dbzeya"))
c1 c2      
-----------
0  "abcde" 
1  "cdefg" 
2  "ecbda" 
3  "bsdee" 
4  "dbzeya"

I want to select the rows that contain the string "*b*d*" in c2, this is how I do it:

pattern:"*b*d*"
select from t where c2 like pattern

but reported an error.

nyi: Not yet implemented

I found this error from the KX official website KX official website, but there is no way to solve this problem, what should I do? Thanks in advance.


Solution

  • Cross-posting answer from:

    https://community.kx.com/t5/kdb-and-q/Why-regular-expression-doesn-t-work-with-bracket/m-p/13492

    kdb+ does not implement full regex.

    https://code.kx.com/q/basics/regex/

    It supports ? * [] ^

    If you want full support you can use the C interface to bring in external libraries

    Or Python: