> For the complete documentation index, see [llms.txt](https://laot7490.gitbook.io/ltbridge/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://laot7490.gitbook.io/ltbridge/utilities/string.md).

# String

## String

Common string operations like trim, split, capitalize, and starts/ends with checks.

### Functions

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Capitalize</strong></td><td>Capitalize first letter of a string.</td><td><a href="#capitalize">#capitalize</a></td></tr><tr><td><strong>EndsWith</strong></td><td>Check if string ends with given suffix.</td><td><a href="#endswith">#endswith</a></td></tr><tr><td><strong>Split</strong></td><td>Split a string by delimiter.</td><td><a href="#split">#split</a></td></tr><tr><td><strong>StartsWith</strong></td><td>Check if string starts with given prefix.</td><td><a href="#startswith">#startswith</a></td></tr><tr><td><strong>TitleCase</strong></td><td>Capitalize first letter of each word.</td><td><a href="#titlecase">#titlecase</a></td></tr><tr><td><strong>Trim</strong></td><td>Trim whitespace from both ends of a string.</td><td><a href="#trim">#trim</a></td></tr></tbody></table>

***

## Capitalize

Capitalize first letter of a string.

{% hint style="info" %}
**Side:** Shared · **Category:** String · **API:** `LT.String.Capitalize`
{% endhint %}

### Example

```lua
local result = LT.String.Capitalize('str')
```

### Parameters

| Name  | Required | Description |
| ----- | -------- | ----------- |
| `str` | Yes      | string      |

### Returns

* `string`

***

## EndsWith

Check if string ends with given suffix.

{% hint style="info" %}
**Side:** Shared · **Category:** String · **API:** `LT.String.EndsWith`
{% endhint %}

### Example

```lua
local result = LT.String.EndsWith('str', 'suffix')
```

### Parameters

| Name     | Required | Description |
| -------- | -------- | ----------- |
| `str`    | Yes      | string      |
| `suffix` | Yes      | string      |

### Returns

* `boolean`

***

## Split

Split a string by delimiter.

{% hint style="info" %}
**Side:** Shared · **Category:** String · **API:** `LT.String.Split`
{% endhint %}

### Example

```lua
LT.String.Split('hello-world-test', '-') -- {'hello', 'world', 'test'}
```

### Parameters

| Name        | Required | Description |
| ----------- | -------- | ----------- |
| `str`       | Yes      | string      |
| `delimiter` | Yes      | string      |

### Returns

* `table`

***

## StartsWith

Check if string starts with given prefix.

{% hint style="info" %}
**Side:** Shared · **Category:** String · **API:** `LT.String.StartsWith`
{% endhint %}

### Example

```lua
local result = LT.String.StartsWith('str', 'prefix')
```

### Parameters

| Name     | Required | Description |
| -------- | -------- | ----------- |
| `str`    | Yes      | string      |
| `prefix` | Yes      | string      |

### Returns

* `boolean`

***

## TitleCase

Capitalize first letter of each word.

{% hint style="info" %}
**Side:** Shared · **Category:** String · **API:** `LT.String.TitleCase`
{% endhint %}

### Example

```lua
LT.String.TitleCase('hello world') -- 'Hello World'
```

### Parameters

| Name  | Required | Description |
| ----- | -------- | ----------- |
| `str` | Yes      | string      |

### Returns

* `string`

***

## Trim

Trim whitespace from both ends of a string.

{% hint style="info" %}
**Side:** Shared · **Category:** String · **API:** `LT.String.Trim`
{% endhint %}

### Example

```lua
local result = LT.String.Trim('str')
```

### Parameters

| Name  | Required | Description |
| ----- | -------- | ----------- |
| `str` | Yes      | string      |

### Returns

* `string`
