replace
Syntax
<string>.replace(old, new[, old2, new2...])replace(input, old, new[, old2, new2...])Arguments
Examples
dasel '"hello world".replace("world", "there")'hello thereNotes
Last updated
The replace function replaces occurrences of one or more substrings within a string.
It supports replacing multiple different substrings in a single call and can be used either as a chained function or with explicit input.
Chained form:
<string>.replace(old, new[, old2, new2...])Function form:
replace(input, old, new[, old2, new2...])input (string, optional when chained)
The string to perform replacements on.
old (string)
The substring to search for.
new (string)
The replacement string.
oldN / newN (string, optional pairs)
Additional replacement pairs. Each old must be followed by its corresponding new.
Chained usage
dasel '"hello world".replace("world", "there")'Output
hello thereFunction usage
Output
Multiple replacements
Output
Replace multiple patterns at once
Output
Replacements are applied in a single pass.
Each replacement must be provided as a pair (old, new).
If an odd number of arguments is supplied, the first argument is treated as the input string.
All arguments must be strings.
Replacement is literal (not regex-based).
Last updated
dasel 'replace("hello world", "world", "there")'hello theredasel '"a-b-c".replace("-", "_", "a", "x")'x_b_cdasel 'replace("one two three", "one", "1", "two", "2", "three", "3")'1 2 3