# KeepChar - script and chart function

KeepChar() returns a string consisting of the first string, 'text', less any of the characters NOT contained in the second string, "keep\_chars".

Syntax:

KeepChar(text, keep\_chars)

Return data type: string

Arguments:

KeepChar arguments

| Argument | Description |
| --- | --- |
| text | The original string. |
| keep\_chars | A string containing the characters in text to be kept. |

Examples and results:

Examples and results

| Example | Result |
| --- | --- |
| `KeepChar<br>( 'a1b2c3','123' )` | Returns '123'. |
| `KeepChar<br>( 'a1b2c3','1234' )` | Returns '123'. |
| `KeepChar<br>( 'a1b22c3','1234' )` | Returns '1223'. |
| `KeepChar ( 'a1b2c3','312' )` | Returns '123' |

## Learn more

* [PurgeChar - script and chart function](https://help.qlik.com/en-US/qlikview/May2024/Subsystems/Client/Content/QV_QlikView/Scripting/StringFunctions/PurgeChar.htm)