Multiple String Search & Replace(SSR) in KDB+/q
When working with text data in q, it’s common to clean or normalize strings before processing them. The built-in ssr function is useful for…
Multiple String Search & Replace(SSR) in KDB+/q

When working with text data in q, it’s common to clean or normalize strings before processing them. The built-in ssr function is useful for search and replace, but many developers overlook how easily it can perform multiple replacements in one step.
Let’s walk through a simple example.
Sample Input
input:"Hi, Can u make to& cha-nge it"
Our string contains a few things we want to clean:
- Remove
& - Replace
uwithyou - Remove
-
Single Replacement with ssr
The ssr function performs a search-and-replace on a string.
ssr[input;"&";""]
"Hi, Can u make to cha-nge it"
Here:
"&"→ the substring to find""→ replace with nothing (effectively removing it)
Multiple Search & Replace Using Over(/)
Instead of running ssr multiple times manually, we can apply it iteratively using over (/).
ssr/[input;("u";"&";"-");("you";"";"")]
"Hi, Can you make to change it"
How It Works
The syntax:
ssr/[string; searchList; replaceList]
Where:
searchList→ list of substrings to findreplaceList→ corresponding replacements
The / operator applies ssr sequentially across the lists, passing the result of each replacement into the next step.
Step-by-Step Concept
Internally this behaves like:
step1:ssr[input;"u";"you"]
step2:ssr[step1;"&";""]
step3:ssr[step2;"-";""]
Result:
"Hi, Can you make to change it"
Using ssr/ keeps the code shorter and more expressive by replacing multiple lines of replacement logic with a single concise expression.
✔️Tip: If you often perform the same replacements, you can store the search and replace lists as variables and reuse them across scripts.
메타데이터
- post_id
- b6be08249dfe
- slug
- multiple-string-search-replace-ssr-in-kdb-q-b6be08249dfe
- url
- https://medium.com/@SathishVadivel/multiple-string-search-replace-ssr-in-kdb-q-b6be08249dfe
- canonical_url
- https://medium.com/@SathishVadivel/multiple-string-search-replace-ssr-in-kdb-q-b6be08249dfe
- author_url
- https://medium.com/@SathishVadivel
- status
- ok
- fetched_at
- 2026-06-22 17:31:34