Skip to content

Modern String ReplaceChars

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › String Library › String Library › ReplaceChars

ReplaceChars

Replaces each character from a set with one given character.

Syntax

ReplaceChars( s, chars, with_ [, ic] )

Notes

  • O(n*k) — length is invariant

Examples

#import "std/strings"
using strings

print ReplaceChars( "abacadabra", "bac", "*" )    '' *****d**r*
print ReplaceChars( "a/b\c", "/\", "." )         '' a.b.c

'' The length never changes, so `with_` must be exactly one unit --
'' anything else returns the string unchanged rather than guessing
print ReplaceChars( "abc", "b", "xy" )            '' abc

Library: String Library
Category: String Library
Documented under: The Functions

Clone this wiki locally