> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kayanos.com/llms.txt
> Use this file to discover all available pages before exploring further.

# String helpers

> Every registered text helper, with signatures and examples for labels, identifiers, messages, and templates.

## When to use these helpers

Use these helpers to clean, format, search, split, and safely present text. Keep identifiers stable; do not use a display transformation as a substitute for a stored business value.

## Calling style

Call a helper as `trim($.request_reference)`. Not every helper is available everywhere: validation, form, and document-template helpers have distinct context contracts. Editor suggestions are not proof that a helper is supported at runtime.

## Complete function reference

### `camelCase`

Converts a string to camel case

**Signature:** `camelCase(str)`

**Example:**

```txt theme={null}
camelCase("hello world") // "helloWorld"
```

**Note:** It can also be written as a transform when the first value is the input: `value | camelCase(...)`.

### `capitalize`

Capitalizes the first letter of a string

**Signature:** `capitalize(str)`

**Example:**

```txt theme={null}
capitalize("hello") // "Hello"
```

**Note:** It can also be written as a transform when the first value is the input: `value | capitalize(...)`.

### `charCount`

Counts the number of characters in a string

**Signature:** `charCount(str)`

**Example:**

```txt theme={null}
charCount("hello") // 5
```

**Note:** It can also be written as a transform when the first value is the input: `value | charCount(...)`.

### `count`

Counts occurrences of a substring in a string

**Signature:** `count(str, search)`

**Example:**

```txt theme={null}
count("hello", "l") // 2
```

**Note:** It can also be written as a transform when the first value is the input: `value | count(...)`.

### `countRegex`

Counts occurrences of a regex in a string

**Signature:** `countRegex(str, regex, flags?)`

**Example:**

```txt theme={null}
countRegex("a1b2c3", "\\d", "g") // 3
```

**Note:** It can also be written as a transform when the first value is the input: `value | countRegex(...)`.

### `endsWith`

Checks if a string ends with a specified substring

**Signature:** `endsWith(str, substring)`

**Example:**

```txt theme={null}
endsWith("hello", "lo") // true
```

**Note:** It can also be written as a transform when the first value is the input: `value | endsWith(...)`.

### `escapeHtml`

Escapes HTML special characters in a string

**Signature:** `escapeHtml(str)`

**Example:**

```txt theme={null}
escapeHtml("<div>hello</div>") // "&lt;div&gt;hello&lt;/div&gt;"
```

**Note:** It can also be written as a transform when the first value is the input: `value | escapeHtml(...)`.

### `initials`

Extracts the initials from a string

**Signature:** `initials(str)`

**Example:**

```txt theme={null}
initials("John Doe") // "JD"
```

**Note:** It can also be written as a transform when the first value is the input: `value | initials(...)`.

### `kebabCase`

Converts a string to kebab case

**Signature:** `kebabCase(str)`

**Example:**

```txt theme={null}
kebabCase("hello world") // "hello-world"
```

**Note:** It can also be written as a transform when the first value is the input: `value | kebabCase(...)`.

### `lines`

Splits a string into an array of lines

**Signature:** `lines(str)`

**Example:**

```txt theme={null}
lines("line1\nline2\nline3") // ["line1", "line2", "line3"]
```

**Note:** It can also be written as a transform when the first value is the input: `value | lines(...)`.

### `lower`

Converts a string to lowercase

**Signature:** `lower(str)`

**Example:**

```txt theme={null}
lower("HELLO") // "hello"
```

**Note:** It can also be written as a transform when the first value is the input: `value | lower(...)`.

### `mask`

Masks a string by replacing characters with a specified character

**Signature:** `mask(str, maskChar, start, end)`

**Example:**

```txt theme={null}
mask("hello world", "*", 2, 8) // "he******d"
```

**Note:** It can also be written as a transform when the first value is the input: `value | mask(...)`.

### `matchRegex`

Returns all matches of a regex against the string

**Signature:** `matchRegex(str, regex, flags?)`

**Example:**

```txt theme={null}
matchRegex("a1b2", "\\d", "g") // ["1","2"]
```

**Note:** It can also be written as a transform when the first value is the input: `value | matchRegex(...)`.

### `normalizeSpace`

Removes duplicate consecutive whitespace characters.

**Signature:** `normalizeSpace(str)`

**Example:**

```txt theme={null}
normalizeSpace("  hello   world  ") // "hello world"
```

**Note:** It can also be written as a transform when the first value is the input: `value | normalizeSpace(...)`.

### `pad`

Pads a string to a specified length with another string

**Signature:** `pad(str, targetLength, padString?)`

**Example:**

```txt theme={null}
pad("hello", 10) // "     hello"
```

**Note:** It can also be written as a transform when the first value is the input: `value | pad(...)`.

### `padEnd`

Pads a string from the end with another string

**Signature:** `padEnd(str, targetLength, padString?)`

**Example:**

```txt theme={null}
padEnd("hello", 10) // "hello     "
```

**Note:** It can also be written as a transform when the first value is the input: `value | padEnd(...)`.

### `padStart`

Pads a string from the start with another string

**Signature:** `padStart(str, targetLength, padString?)`

**Example:**

```txt theme={null}
padStart("hello", 10) // "     hello"
```

**Note:** It can also be written as a transform when the first value is the input: `value | padStart(...)`.

### `pascalCase`

Converts a string to Pascal case

**Signature:** `pascalCase(str)`

**Example:**

```txt theme={null}
pascalCase("hello world") // "HelloWorld"
```

**Note:** It can also be written as a transform when the first value is the input: `value | pascalCase(...)`.

### `repeat`

Repeats a string a specified number of times

**Signature:** `repeat(str, count)`

**Example:**

```txt theme={null}
repeat("hello", 3) // "hellohellohello"
```

**Note:** It can also be written as a transform when the first value is the input: `value | repeat(...)`.

### `replace`

Replaces the first occurrence of a substring with another string

**Signature:** `replace(str, oldStr, newStr)`

**Example:**

```txt theme={null}
replace("hello world", "world", "there") // "hello there"
```

**Note:** It can also be written as a transform when the first value is the input: `value | replace(...)`.

### `replaceAll`

Replaces all occurrences of a substring with another string

**Signature:** `replaceAll(str, oldStr, newStr)`

**Example:**

```txt theme={null}
replaceAll("hello world world", "world", "there") // "hello there there"
```

**Note:** It can also be written as a transform when the first value is the input: `value | replaceAll(...)`.

### `replaceLast`

Replaces the last occurrence of a substring with another string

**Signature:** `replaceLast(str, search, replace)`

**Example:**

```txt theme={null}
replaceLast("a-b-c-b", "b", "X") // "a-b-c-X"
```

**Note:** It can also be written as a transform when the first value is the input: `value | replaceLast(...)`.

### `replaceRegex`

Replaces substrings matched by a regex pattern with a replacement string

**Signature:** `replaceRegex(str, regex, replace, flags?)`

**Example:**

```txt theme={null}
replaceRegex("abc123", "\\d+", "#") // "abc#"
```

**Note:** It can also be written as a transform when the first value is the input: `value | replaceRegex(...)`.

### `slug`

Converts a string to a URL-friendly slug

**Signature:** `slug(str)`

**Example:**

```txt theme={null}
slug("Hello World!") // "hello-world"
```

**Note:** It can also be written as a transform when the first value is the input: `value | slug(...)`.

### `snakeCase`

Converts a string to snake case

**Signature:** `snakeCase(str)`

**Example:**

```txt theme={null}
snakeCase("hello world") // "hello_world"
```

**Note:** It can also be written as a transform when the first value is the input: `value | snakeCase(...)`.

### `split`

Splits a string into an array of substrings

**Signature:** `split(str, separator)`

**Example:**

```txt theme={null}
split("a,b,c", ",") // ["a", "b", "c"]
```

**Note:** It can also be written as a transform when the first value is the input: `value | split(...)`.

### `startsWith`

Checks if a string starts with a specified substring

**Signature:** `startsWith(str, substring)`

**Example:**

```txt theme={null}
startsWith("hello", "he") // true
```

**Note:** It can also be written as a transform when the first value is the input: `value | startsWith(...)`.

### `substr`

Extracts a substring from a string

**Signature:** `substr(str, start, end?)`

**Example:**

```txt theme={null}
substr("hello", 1, 3) // "el"
```

**Note:** It can also be written as a transform when the first value is the input: `value | substr(...)`.

### `titleCase`

Converts a string to title case

**Signature:** `titleCase(str)`

**Example:**

```txt theme={null}
titleCase("hello world") // "Hello World"
```

**Note:** It can also be written as a transform when the first value is the input: `value | titleCase(...)`.

### `trim`

Removes whitespace from both ends of a string

**Signature:** `trim(str)`

**Example:**

```txt theme={null}
trim("  hello  ") // "hello"
```

**Note:** It can also be written as a transform when the first value is the input: `value | trim(...)`.

### `trimEnd`

Removes whitespace from the end of a string

**Signature:** `trimEnd(str)`

**Example:**

```txt theme={null}
trimEnd("  hello  ") // "  hello"
```

**Note:** It can also be written as a transform when the first value is the input: `value | trimEnd(...)`.

### `trimStart`

Removes whitespace from the start of a string

**Signature:** `trimStart(str)`

**Example:**

```txt theme={null}
trimStart("  hello  ") // "hello  "
```

**Note:** It can also be written as a transform when the first value is the input: `value | trimStart(...)`.

### `truncate`

Truncates a string to a specified length

**Signature:** `truncate(str, length)`

**Example:**

```txt theme={null}
truncate("hello world", 5) // "hello"
```

**Note:** It can also be written as a transform when the first value is the input: `value | truncate(...)`.

### `unescapeHtml`

Unescapes HTML special characters in a string

**Signature:** `unescapeHtml(str)`

**Example:**

```txt theme={null}
unescapeHtml("&lt;div&gt;hello&lt;/div&gt;") // "<div>hello</div>"
```

**Note:** It can also be written as a transform when the first value is the input: `value | unescapeHtml(...)`.

### `upper`

Converts a string to uppercase

**Signature:** `upper(str)`

**Example:**

```txt theme={null}
upper("hello") // "HELLO"
```

**Note:** It can also be written as a transform when the first value is the input: `value | upper(...)`.

### `wordCount`

Counts the number of words in a string

**Signature:** `wordCount(str)`

**Example:**

```txt theme={null}
wordCount("hello world") // 2
```

**Note:** It can also be written as a transform when the first value is the input: `value | wordCount(...)`.

## Before you publish

* Start with a known value and confirm the expected result.
* Handle null, empty text, and empty lists deliberately.
* Do not place secrets, access tokens, or sensitive personal data in an expression.
* Read [expression contexts and availability](/reference/expressions/contexts) before copying an expression between features.

![String helpers in KayanOS](https://kayanos.app/docs-images/en/reference/expressions-helpers-string.png)
