Hi All,
I would like to use **\* pattern** in **ss** function ([https://code.kx.com/v2/kb/regex/]("https://code.kx.com/v2/kb/regex/")and[https://code.kx.com/v2/ref/ss/]("https://code.kx.com/v2/ref/ss/")) but i can't . it works fine for **"like"** but not for ss/ssr
please advice
"test\_p.xxx" ss "?\_p.?" / works fine
"test\_p.xxx" like "\*\_p.\*" / works fine
BUT
"test\_p.xxx" ss "\*\_p.\*" / doesn't work
q)"test\_p.xxx" ss "\*\_p.\*"
'length
[0]"test\_p.xxx" ss "\*\_p.\*"
This is by design most likely. Since ss gives the index/indices of where your substring begins, e.g.
q)“test_p.xxx” ss “?_p.?”
,3
q)“test_p.xxx” ss “??_p.?”
,2
q)“test_p.xxx” ss “???_p.?”
,1
then it wouldn’t know what the starting index is if you supply a open-ended wildcard such as “*_p.*”
Terry
Hi Terry,
then it wouldn’t know what the starting index is if you supply a open-ended wildcard such as “*_p.*”
Hm… why not 0 for my first example ( “test_p.xxx” , and wild card is “*_p.*”)
or why not 4 for the following example
“test_p.xxx” ss “_p.*”
This is by design most likely. Since ss gives the index/indices of where your substring begins, e.g.
q)“test_p.xxx” ss “?_p.?”
,3
q)“test_p.xxx” ss “??_p.?”
,2
q)“test_p.xxx” ss “???_p.?”
,1
then it wouldn’t know what the starting index is if you supply a open-ended wildcard such as “*_p.*”
Terry
You can always create a custom ss function!
q)ss1:{$["*"=first y;(
long$();0)x like y;““=last y;x ss ssr[y;””;“?”];x ss y]};q)q)ss1[“test_p.xxx”;“_p.”]0q)ss1[“test_p.xxx”;“_p.*”],4`
I haven’t tested this a whole lot but it might achieve what you’re looking for.
Terry
Yes, i know… Also i can use c++ extension but i asked to be sure that i didn’t miss something
Thanks a lot
13:44, October 1, 2019, TerryLynch <tlyncher@gmail.com>:
You can always create a custom ss function!
q)ss1:{$["*"=first y;(
long$();0)x like y;““=last y;x ss ssr[y;””;“?”];x ss y]};q)q)ss1[“test_p.xxx”;“_p.”]0q)ss1[“test_p.xxx”;“_p.*”],4`I haven’t tested this a whole lot but it might achieve what you’re looking for.
Terry
On Monday, September 30, 2019 at 8:23:44 PM UTC+1, Igor M wrote:
Hi Terry,
then it wouldn’t know what the starting index is if you supply a open-ended wildcard such as “*_p.*”
Hm… why not 0 for my first example ( “test_p.xxx” , and wild card is “*_p.*”)
or why not 4 for the following example
“test_p.xxx” ss “_p.*”
This is by design most likely. Since ss gives the index/indices of where your substring begins, e.g.
q)“test_p.xxx” ss “?_p.?”
,3
q)“test_p.xxx” ss “??_p.?”
,2
q)“test_p.xxx” ss “???_p.?”
,1
then it wouldn’t know what the starting index is if you supply a open-ended wildcard such as “*_p.*”
Terry
On Sunday, September 29, 2019 at 1:24:37 PM UTC+1, Igor M wrote:
Hi All,
I would like to use * pattern in ss function (https://code.kx.com/v2/kb/regex/andhttps://code.kx.com/v2/ref/ss/) but i can’t . it works fine for “like” but not for ss/ssr
please advice
“test_p.xxx” ss “?_p.?” / works fine
“test_p.xxx” like “*_p.*” / works fineBUT
“test_p.xxx” ss “*_p.*” / doesn’t workq)“test_p.xxx” ss “*_p.*”
'length
[0]“test_p.xxx” ss “*_p.*”–
Submitted via Google Groups