Skip to content

Modern String RetainChars

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

Home › String Library › String Library › RetainChars

RetainChars

Keeps only the characters that belong to a set.

Syntax

RetainChars( s, chars [, ic] )

Notes

  • O(n*k)

Examples

#import "std/strings"
using strings

print RetainChars( "abacadabra", "bc" )        '' bcb
print RetainChars( "(555) 123-4567", "0123456789" )    '' 5551234567
print RetainChars( "abacadabra", "" )          '' (empty) -- the complement of RemoveChars

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

Clone this wiki locally