kdb

how to ssr more than one string in a table at the same time


I would like to replace for more than one condition:

Example:

tab:([]a:`a`b`c;b:("abc-d";"rdf,e";"ertfg"))

update b:{ssr[x;"-"|",";" "]} each b from tab

I couldn't replace for both - and , at the same time, it can only take one. I tried to join each both with b but it doesn't work well.


Solution

  • You can achieve this using over (/)

    q)update ssr/[;("-";",");" "]each b from tab
    a b
    ---------
    a "abc d"
    b "rdf e"
    c "ertfg"