# KeepChar - fonction de script et fonction de graphique

KeepChar() renvoie une chaîne composée de la première chaîne ('text'), déduction faite des caractères NON contenus dans la deuxième chaîne ("keep\_chars").

KeepChar(text, keep\_chars)

chaîne

Arguments

| Argument | Description |
| --- | --- |
| text | Chaîne d'origine. |
| keep\_chars | Chaîne contenant les caractères figurant dans text à conserver. |

[](https://help.qlik.com/en-US/sense/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/KeepChar.htm)

#### Exemple : Expressions de graphique

| Exemple | Résultat |
| --- | --- |
| `KeepChar   ( 'a1b2c3','123' )` | Renvoie 123. |
| `KeepChar   ( 'a1b2c3','1234' )` | Renvoie 123. |
| `KeepChar   ( 'a1b22c3','1234' )` | Renvoie 1223. |
| `KeepChar   ( 'a1b2c3','312' )` | Renvoie 123. |

[](https://help.qlik.com/en-US/sense/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/KeepChar.htm)

#### Exemple : Script de chargement et résultats

```
T1:
Load 
*, 
keepchar(String1, String2) as KeepChar;  
Load * inline [
String1, String2
'a1b2c3', '123'
]; 
				
```

Résultats

Table Qlik SenseQlik Sense affichant les résultats obtenus suite à l'utilisation de la fonction KeepCharKeepChar dans le script de chargement.

| String1 | String2 | KeepChar |
| --- | --- | --- |
| a1b2c3 | 123 | 123 |

## En savoir plus

* [PurgeChar - fonction de script et fonction de graphique](https://help.qlik.com/fr-FR/sense/May2025/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/PurgeChar.htm)