---
name: "trim"
type: command
status: ok
groups: ["Strings"]
arma3_since: "2.02"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/trim
revid: 377062
updated: 2026-01-01T09:06:47Z
---

# trim

*Command · Strings · Arma 3 v2.02*

## Description

Trims a [string](../topics/String.md).

## Syntax

### Syntax 1

```sqf
trim stringValue
```

**Parameters:**

- `stringValue`: [String](../topics/String.md) - string to be trimmed. spaces, tabs and line returns are removed from both ends of *stringValue*.

**Returns:** [String](../topics/String.md) - trimmed string

### Syntax 2

```sqf
string trim [chars, where]
```

**Parameters:**

- `string`: [String](../topics/String.md) - string to be trimmed
- `chars`: [String](../topics/String.md) - list of characters to be trimmed
- `where`: [Number](../topics/Number.md) one of:
  - 0 - trim at the beginning (left) and the end (right)
  - 1 - trim at the beginning (left)
  - 2 - trim at the end (right)

**Returns:** [String](../topics/String.md) - trimmed string

## Examples

### Example 1

```sqf
trim "        hello, how are you?  "; // returns "hello, how are you?"
```

### Example 2

```sqf
"hewosentence!123" trim ["3e1o2hw", 0]; // returns "sentence!"
```

## See also

[select](../commands/select.md)

<sub>Source: [BI Community Wiki — trim](https://community.bistudio.com/wiki/trim) (revision 377062).</sub>
