# ltrim

[Read this page in HTML](https://www.scopedb.io/docs/reference/functions/string/ltrim)

Removes leading characters from a string.

## Syntax

```scopeql
ltrim(<string> [, chars => <chars>])
```

## Arguments

| Argument   | Type     | Description                                                                                                                                     |
| ---------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `<string>` | `string` | String to trim.                                                                                                                                 |
| `chars`    | `string` | Optional constant; defaults to `' \t\n\r'`. Set of characters to remove: space, tab, newline, and carriage return by default. Must not be NULL. |

## Returns

Returns `string`. Returns NULL if the input is NULL. An empty `chars` string leaves the input unchanged.

## Examples

### Clean padded event fields

Remove whitespace from the start of imported labels. Brackets make the remaining spaces visible in the result.

```scopeql
VALUES ('  checkout'), (' catalog')
SELECT $0 AS raw_label
SELECT '[' || raw_label || ']' AS before, '[' || ltrim(raw_label) || ']' AS after
```

```text
+--------------+------------+
| before       | after      |
+--------------+------------+
| [  checkout] | [checkout] |
| [ catalog]   | [catalog]  |
+--------------+------------+
```

### Remove producer formatting

Specify which characters to remove:

```scopeql
SELECT ltrim('##payment_failed', chars => '#') AS event
```

```text
+----------------+
| event          |
+----------------+
| payment_failed |
+----------------+
```

`chars` is a set of individual characters to remove, not a literal prefix or suffix to match.
