User Tools

Site Tools


KeepChars(text, keep_string)

Category: Text function


This function keeps only the characters given in keep_string and removes the others from text.


textTextThe text value to search within for the after_string string.
keep_stringText (must not be empty)A string of individual characters within text to keep, removing all other characters.

Return value type: Text


This function is case sensitive.

text and keep_string are implicitly converted to text values if required.

The retained characters appear in the result in the order they appear in text.

If none of the characters in keep_string are found, an (empty) value is returned.


keepchars('a1b2c3', 'abc') //Returns 'abc'
keepchars('a1b2c3', 'cba') //Returns 'abc'
keepchars('3b2d1', '123') //Returns '321'
keepchars('Canada', 'acx') //Returns 'aaa'  ('C' not kept due to case mismatch; no 'x' in 'Canada')
keepchars('Canada', 'Ca') //Returns 'Caaa'
keepchars('Canada', 'zxw') //Returns (empty)  ('z', 'x', nor 'w' are found in 'Canada')

See also

syntax/functions/keepchars.txt · Last modified: 2021/08/14 22:13 by craigt

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki