User Tools

Site Tools


syntax:functions:keepchars

This is an old revision of the document!


KeepChars(text, keep_string)

Category: Text function


Description

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


Arguments

ArgumentTypeDescription
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


Remarks

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.


Examples

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


See also

syntax/functions/keepchars.1627886229.txt.gz · Last modified: 2021/08/02 02:37 by craigt

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki