# KeepChar – função de script e gráfico

KeepChar() retorna uma string que consiste na primeira string, "text", menos qualquer caractere NÃO contido na segunda string, "keep\_chars".

Sintaxe:

KeepChar(text, keep\_chars)

Tipo de dados de retorno: caractere

Argumentos:

Argumentos

| Argumento | Descrição |
| --- | --- |
| text | A string original. |
| keep\_chars | Uma string contendo os caracteres no text a ser mantido. |

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

#### Exemplo: expressões de gráfico

| Exemplo | Resultado |
| --- | --- |
| `KeepChar   ( 'a1b2c3','123' )` | Retorna '123'. |
| `KeepChar   ( 'a1b2c3','1234' )` | Retorna '123'. |
| `KeepChar   ( 'a1b22c3','1234' )` | Retorna '1223'. |
| `KeepChar   ( 'a1b2c3','312' )` | Retorna '123'. |

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

#### Exemplo: script de carregamento e resultados

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

Resultados

Tabela do Qlik SenseQlik Sense mostrando a saída do uso da função KeepCharKeepChar no script de carregamento.

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

## Saiba mais

* [PurgeChar – função de script e gráfico](https://help.qlik.com/pt-BR/sense/November2024/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/PurgeChar.htm)