How to perform a pattern matching operation on a long data type in

How to perform a pattern matching operation on a long data type in Kdb?

All of the following give me a type error: select instrument from Table where time=14201% select instrument from Table where time=14201\* select instrument from Table where time=14201%
select instrument from Table where time=“14201*”
select instrument from Table where time=like"14201*"
select instrument from Table where time like"14201*"
select instrument from Table where time like 14201*
selec instrument from Table where time like ‘14201%’
select instrument from Table where time like ‘14201%’
select instrument from Table where time like 14201*
select instrument from Table where time like “14201*”
select instrument from Table where time like “14201*       
select instrument from Table where time like"14201*”

These work:
select instrument from Table where time=1418234533892319745
select instrument from Table where instrument like “6E*”

These do not work either:
select instrument from Table where time > 124400000
select instrument from Table where time > 124400
select instrument from Table where time < 1    
select instrument from Table where time < 1 

Some good resource I found:
http://www.timestored.com/b/forums/topic/string-functions-like-search-replace-regex/
http://www.kx.com/q/d/kdb+1.htm

see http://code.kx.com/wiki/Reference/like

it only works with strings/symbols. Out of the box regex is pretty
simple, as you’ve already discovered.

if you really want to match a non-string column with a regex with
like, you have to stringify it:

select from x where string[time] like “*08:00*”

Although I think in most cases I’m sure there’s a far more efficient
way of doing it!!

The column time is from type long so pattern matching cannot be used directly here. You can use within here<o:p></o:p>

<o:p> </o:p>

q) select instrument  from Table where time within 1420000000000000000 1430000000000000000<o:p></o:p>

<o:p> </o:p>

If you really want to use pattern matching then cast time to string first<o:p></o:p>

<o:p> </o:p>

q) select instrument from  Table where string[time] like “14201*”<o:p></o:p>

<o:p> </o:p>

HTH,<o:p></o:p>

<o:p> </o:p>

Kim<o:p></o:p>

<o:p> </o:p>

<o:p> </o:p>

Von: personal-kdbplus@googlegroups.com [mailto:personal-kdbplus@googlegroups.com] Im Auftrag von A.L.V.
Gesendet: Donnerstag, 26. Februar 2015 23:17
An: personal-kdbplus@googlegroups.com
Betreff: [personal kdb+] How to perform a pattern matching operation on a long data type in Kdb?<o:p></o:p>

<o:p> </o:p>

How to perform a pattern matching operation on a long data type in Kdb?

All of the following give me a type error: select instrument from Table where time=14201% select instrument from Table where time=14201\* select instrument from Table where time=14201%
select instrument from Table where time=“14201*”
select instrument from Table where time=like"14201*"
select instrument from Table where time like"14201*"
select instrument from Table where time like 14201*
selec instrument from Table where time like ‘14201%’
select instrument from Table where time like ‘14201%’
select instrument from Table where time like 14201*
select instrument from Table where time like “14201*”
select instrument from Table where time like “14201*       
select instrument from Table where time like"14201*”

These work:
select instrument from Table where time=1418234533892319745
select instrument from Table where instrument like “6E*”

These do not work either:
select instrument from Table where time > 124400000
select instrument from Table where time > 124400
select instrument from Table where time < 1    
select instrument from Table where time < 1 

Some good resource I found:
http://www.timestored.com/b/forums/topic/string-functions-like-search-replace-regex/
http://www.kx.com/q/d/kdb+1.htm<o:p></o:p>


Submitted via Google Groups