how do i compare the special string in query

Viewed 148

I would like to query and there is special character in the table

For example:

tab:([]a:("ab*cd*ef";"3rr3f";"fewfa");b:1 2 3)

I tried this

select from tab where a like "ab*cd*ef"

This doesnt work. I am using this in a function so it will extract the exact word to a variable

 variable:"ab*cd*ef"

and I use this variable to match with another table. wondering how this should work

1 Answers

* is a wildcard for matching any sequence of characters. Unfortunately kdb doesn't support complicated regex out of the box but you can escape * in this case with the notation for lists of alternatives.

q)select from tab where a like "ab[*]cd[*]ef"
a          b
------------
"ab*cd*ef" 1

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

Related