Hello:
I’d like to remove string “c 12345” from “abc 12345 def” with
q)ssr[“abc 12345 def”; “c [0-9]*”; “”]
but got the following error.
k){,/@[x;1+2*!_.5*#x:(0,/(0,{n:x?“[”;$[n=#x;n;n+.z.s$[(#x)=p:x?“]”;'“unmatched ]”;p]_x:(n+2+“^”=x n+1)_x]}y,“”)+/:x ss y)_x;$[100h>@z;:[;z];z]]}
'length
ss
"abc 12345 def
Does any body have a solution? Please note the above string is just part of a huge string, so the solution need to be general.
Thanks in advance.
Attila
2
q)ssr[“abc 12345 def”;“c [0-9][0-9][0-9][0-9][0-9]”;“”]
"ab def
or if that is not enough http://code.kx.com/wiki/Cookbook/regex
Thank you Attila.
the number of digits is not fixed, so I’ll need regex, or write something myself in q.
AE1
4
{$[x~a:ssr[x;“c [0-9]”;"c "];ssr[a;“c “;””];.z.s[a]]}
But a lot of problems here if string is long.
Why not;
q)a:“abc 12345 def”
q)a where not a in “c 12345”
“abdef”
?
12345 is just an example. I would like to remove numbers with certain prefix( c here)
That would remove *every* instance of “c” or “1” or “2” etc from the string rather than the specific case of the letter followed by numerics.
For example, what if the string is
a:“cabc 12345 def”