wwarby
wwarby

Reputation: 2051

Escape the * character in KDB SQL "like" queries

I have a scenario where I have data in my KDB table that contains multiple consecutive asterisk characters in a string, and I need to be able to search for that string. Suppose the string I'm searching for is foo**bar, the query I'd want to write is:

select from table where column like "foo**bar" 

I need to escape the * characters, but I can't find in the docs how to do that. I've tried backslash and a couple of other variants without success. Presumably this must be possible?

Upvotes: 1

Views: 2959

Answers (2)

Benjaminliupenrose
Benjaminliupenrose

Reputation: 76

Now, you can use re2 with kdb+/q. Will always recommend using some standard regex for this task, instead of like

Upvotes: 0

Anton Dovzhenko
Anton Dovzhenko

Reputation: 2569

Square brackets work as escape character with like

"foo**bar" like "foo[*][*]bar"

Here is a quote from Kx wiki:

Special characters can be matched by bracketing them

Upvotes: 5

Related Questions