String module

replace_chars

procedure · 1 overloadSource

Overwrites every byte of s that is in chars with replacement. s is changed in place, so it must not be a string literal.

replace_chars :: (s: string, chars: string, replacement: u8)

Parameters

s: string
chars: string
replacement: u8
ExampleOpen in playground ↗
text := copy_string("a-b_c");
defer free(text);
replace_chars(text, "-_", #char " ");
assert(text == "a b c");

See also