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

# str functions

> Reference for the 17 functions (74 entries with overloads) of the str namespace: str.contains, str.endswith, str.format_time, str.length and 13 more, each with its definition and an example.

> [!NOTE]
>
> Language version: 2 · Reference version: 2.7 · Date: 2026-10-25 · Compiler build: df7b3b14 · Namespace: str · Entries: 75

## `str` (library)

**Definition**

Seventeen functions for working with text: tests such as `str.contains` and `str.startswith`, transformations such as `str.replace` and `str.substring`, conversions in both directions with `str.tonumber` and `str.tostring`, and `str.format_time` for rendering a time.

Use these to build an alert message or a plot's text, not to alter chart data.

**Notes**

* A string has no method form: `s.length()` is rejected. Call the function with the string as its first argument: `str.length(s)`.

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str Library Example", overlay=true)
if barstate.islast {
    name = str.upper(syminfo.ticker)
    txt = name + " closed at " + str.tostring(math.round(close, 2))
    label.new(bar_index, high, text=str.contains(name, "USD") ? txt + " (USD pair)" : txt)
}
```

## `str.contains` (function, overload 1)

**Definition**

Tests whether one string occurs inside another.

Both arguments are required, and the function carries one signature per form of them.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.contains(const string source, const string str) → const bool
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `const string` | yes | Source string. |
| `str` | `const string` | yes | The substring to search for. |

**Returns**

`const bool`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Contains Example", overlay=false)
ticker = syminfo.ticker
isForex = str.contains(ticker, "USD")
plot(isForex ? 1 : 0, title="Contains USD", color=isForex ? color.green : color.red, style=plotStyle.bar)
```

## `str.contains` (function, overload 2)

**Definition**

Tests whether one string occurs inside another.

Both arguments are required, and the function carries one signature per form of them.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.contains(input string source, input string str) → input bool
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `input string` | yes | Source string. |
| `str` | `input string` | yes | The substring to search for. |

**Returns**

`input bool`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Contains Example", overlay=false)
ticker = syminfo.ticker
isForex = str.contains(ticker, "USD")
plot(isForex ? 1 : 0, title="Contains USD", color=isForex ? color.green : color.red, style=plotStyle.bar)
```

## `str.contains` (function, overload 3)

**Definition**

Tests whether one string occurs inside another.

Both arguments are required, and the function carries one signature per form of them.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.contains(simple string source, simple string str) → simple bool
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `simple string` | yes | Source string. |
| `str` | `simple string` | yes | The substring to search for. |

**Returns**

`simple bool`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Contains Example", overlay=false)
ticker = syminfo.ticker
isForex = str.contains(ticker, "USD")
plot(isForex ? 1 : 0, title="Contains USD", color=isForex ? color.green : color.red, style=plotStyle.bar)
```

## `str.contains` (function, overload 4)

**Definition**

Tests whether one string occurs inside another.

Both arguments are required, and the function carries one signature per form of them.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.contains(series string source, series string str) → series bool
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `series string` | yes | Source string. |
| `str` | `series string` | yes | The substring to search for. |

**Returns**

`series bool`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Contains Example", overlay=false)
ticker = syminfo.ticker
isForex = str.contains(ticker, "USD")
plot(isForex ? 1 : 0, title="Contains USD", color=isForex ? color.green : color.red, style=plotStyle.bar)
```

## `str.endswith` (function, overload 1)

**Definition**

Asks whether a string finishes with a given ending.

The suffix is a string, not a pattern, and both arguments are required.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.endswith(const string source, const string suffix) → const bool
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `const string` | yes | Source string. |
| `suffix` | `const string` | yes | The substring to search for. |

**Returns**

`const bool`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Contains Example", overlay=false)
ticker = syminfo.ticker
isForex = str.endswith(ticker, "USD")
plot(isForex ? 1 : 0, title="Contains USD", color=isForex ? color.green : color.red, style=plotStyle.bar)
```

## `str.endswith` (function, overload 2)

**Definition**

Asks whether a string finishes with a given ending.

The suffix is a string, not a pattern, and both arguments are required.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.endswith(input string source, input string suffix) → input bool
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `input string` | yes | Source string. |
| `suffix` | `input string` | yes | The substring to search for. |

**Returns**

`input bool`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Contains Example", overlay=false)
ticker = syminfo.ticker
isForex = str.endswith(ticker, "USD")
plot(isForex ? 1 : 0, title="Contains USD", color=isForex ? color.green : color.red, style=plotStyle.bar)
```

## `str.endswith` (function, overload 3)

**Definition**

Asks whether a string finishes with a given ending.

The suffix is a string, not a pattern, and both arguments are required.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.endswith(simple string source, simple string suffix) → simple bool
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `simple string` | yes | Source string. |
| `suffix` | `simple string` | yes | The substring to search for. |

**Returns**

`simple bool`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Contains Example", overlay=false)
ticker = syminfo.ticker
isForex = str.endswith(ticker, "USD")
plot(isForex ? 1 : 0, title="Contains USD", color=isForex ? color.green : color.red, style=plotStyle.bar)
```

## `str.endswith` (function, overload 4)

**Definition**

Asks whether a string finishes with a given ending.

The suffix is a string, not a pattern, and both arguments are required.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.endswith(series string source, series string suffix) → series bool
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `series string` | yes | Source string. |
| `suffix` | `series string` | yes | The substring to search for. |

**Returns**

`series bool`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Contains Example", overlay=false)
ticker = syminfo.ticker
isForex = str.endswith(ticker, "USD")
plot(isForex ? 1 : 0, title="Contains USD", color=isForex ? color.green : color.red, style=plotStyle.bar)
```

## `str.format_time` (function, overload 1)

**Definition**

Renders a time as text, in a format and a time zone you give.

`time_value` is in **seconds** since 1970-01-01 UTC, unlike `time`, `timenow` and the other Lipi times, which are in milliseconds: pass `math.floor(time / 1000)`. `format` is required and is written as a pattern of the reference date 2006-01-02 15:04:05 (for example `"2006-01-02 15:04"` or `"02 Jan 15:04"`). `timezone` defaults to `"UTC"`; an unknown time zone gives `na`.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.format_time(const int time_value, const string format, const string timezone) → const string
```

**Parameters**

| Name | Type | Required | Description | Default |
| - | - | - | - | - |
| `time_value` | `const int` | yes | The time to render, in seconds since 1970-01-01 UTC. Lipi's own times are in milliseconds: divide by 1000 and round down with `math.floor`. | |
| `format` | `const string` | yes | The layout of the result, written as the reference date 2006-01-02 15:04:05 would appear: `2006` year, `01` month, `Jan` month name, `02` day, `15` hour (24-hour), `03` hour (12-hour), `04` minute, `05` second, `PM` the half of the day, `Mon` weekday. Required. | |
| `timezone` | `const string` | no | The time zone of the result, in UTC/GMT notation (such as `"UTC-5"` or `"GMT+0530"`) or as an IANA time zone name (such as `"America/New_York"`). Optional; the default is `"UTC"`. An unknown name gives `na`. | `"UTC"` |

**Returns**

`const string`

**Notes**

* `time_value` takes an int. A division such as `time / 1000` gives a float and is rejected; wrap it in `math.floor` to get an int.

**Example**

```lipi wrap theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.format_time Example", overlay=true)
if barstate.islast {
    label.new(bar_index, high, text=str.format_time(math.floor(time / 1000), "2006-01-02 15:04", syminfo.timezone))
}
```

## `str.format_time` (function, overload 2)

**Definition**

Renders a time as text, in a format and a time zone you give.

`time_value` is in **seconds** since 1970-01-01 UTC, unlike `time`, `timenow` and the other Lipi times, which are in milliseconds: pass `math.floor(time / 1000)`. `format` is required and is written as a pattern of the reference date 2006-01-02 15:04:05 (for example `"2006-01-02 15:04"` or `"02 Jan 15:04"`). `timezone` defaults to `"UTC"`; an unknown time zone gives `na`.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.format_time(input int time_value, input string format, input string timezone) → input string
```

**Parameters**

| Name | Type | Required | Description | Default |
| - | - | - | - | - |
| `time_value` | `input int` | yes | The time to render, in seconds since 1970-01-01 UTC. Lipi's own times are in milliseconds: divide by 1000 and round down with `math.floor`. | |
| `format` | `input string` | yes | The layout of the result, written as the reference date 2006-01-02 15:04:05 would appear: `2006` year, `01` month, `Jan` month name, `02` day, `15` hour (24-hour), `03` hour (12-hour), `04` minute, `05` second, `PM` the half of the day, `Mon` weekday. Required. | |
| `timezone` | `input string` | no | The time zone of the result, in UTC/GMT notation (such as `"UTC-5"` or `"GMT+0530"`) or as an IANA time zone name (such as `"America/New_York"`). Optional; the default is `"UTC"`. An unknown name gives `na`. | `"UTC"` |

**Returns**

`input string`

**Notes**

* `time_value` takes an int. A division such as `time / 1000` gives a float and is rejected; wrap it in `math.floor` to get an int.

**Example**

```lipi wrap theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.format_time Example", overlay=true)
if barstate.islast {
    label.new(bar_index, high, text=str.format_time(math.floor(time / 1000), "2006-01-02 15:04", syminfo.timezone))
}
```

## `str.format_time` (function, overload 3)

**Definition**

Renders a time as text, in a format and a time zone you give.

`time_value` is in **seconds** since 1970-01-01 UTC, unlike `time`, `timenow` and the other Lipi times, which are in milliseconds: pass `math.floor(time / 1000)`. `format` is required and is written as a pattern of the reference date 2006-01-02 15:04:05 (for example `"2006-01-02 15:04"` or `"02 Jan 15:04"`). `timezone` defaults to `"UTC"`; an unknown time zone gives `na`.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.format_time(simple int time_value, simple string format, simple string timezone) → simple string
```

**Parameters**

| Name | Type | Required | Description | Default |
| - | - | - | - | - |
| `time_value` | `simple int` | yes | The time to render, in seconds since 1970-01-01 UTC. Lipi's own times are in milliseconds: divide by 1000 and round down with `math.floor`. | |
| `format` | `simple string` | yes | The layout of the result, written as the reference date 2006-01-02 15:04:05 would appear: `2006` year, `01` month, `Jan` month name, `02` day, `15` hour (24-hour), `03` hour (12-hour), `04` minute, `05` second, `PM` the half of the day, `Mon` weekday. Required. | |
| `timezone` | `simple string` | no | The time zone of the result, in UTC/GMT notation (such as `"UTC-5"` or `"GMT+0530"`) or as an IANA time zone name (such as `"America/New_York"`). Optional; the default is `"UTC"`. An unknown name gives `na`. | `"UTC"` |

**Returns**

`simple string`

**Notes**

* `time_value` takes an int. A division such as `time / 1000` gives a float and is rejected; wrap it in `math.floor` to get an int.

**Example**

```lipi wrap theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.format_time Example", overlay=true)
if barstate.islast {
    label.new(bar_index, high, text=str.format_time(math.floor(time / 1000), "2006-01-02 15:04", syminfo.timezone))
}
```

## `str.format_time` (function, overload 4)

**Definition**

Renders a time as text, in a format and a time zone you give.

`time_value` is in **seconds** since 1970-01-01 UTC, unlike `time`, `timenow` and the other Lipi times, which are in milliseconds: pass `math.floor(time / 1000)`. `format` is required and is written as a pattern of the reference date 2006-01-02 15:04:05 (for example `"2006-01-02 15:04"` or `"02 Jan 15:04"`). `timezone` defaults to `"UTC"`; an unknown time zone gives `na`.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.format_time(series int time_value, series string format, series string timezone) → series string
```

**Parameters**

| Name | Type | Required | Description | Default |
| - | - | - | - | - |
| `time_value` | `series int` | yes | The time to render, in seconds since 1970-01-01 UTC. Lipi's own times are in milliseconds: divide by 1000 and round down with `math.floor`. | |
| `format` | `series string` | yes | The layout of the result, written as the reference date 2006-01-02 15:04:05 would appear: `2006` year, `01` month, `Jan` month name, `02` day, `15` hour (24-hour), `03` hour (12-hour), `04` minute, `05` second, `PM` the half of the day, `Mon` weekday. Required. | |
| `timezone` | `series string` | no | The time zone of the result, in UTC/GMT notation (such as `"UTC-5"` or `"GMT+0530"`) or as an IANA time zone name (such as `"America/New_York"`). Optional; the default is `"UTC"`. An unknown name gives `na`. | `"UTC"` |

**Returns**

`series string`

**Notes**

* `time_value` takes an int. A division such as `time / 1000` gives a float and is rejected; wrap it in `math.floor` to get an int.

**Example**

```lipi wrap theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.format_time Example", overlay=true)
if barstate.islast {
    label.new(bar_index, high, text=str.format_time(math.floor(time / 1000), "2006-01-02 15:04", syminfo.timezone))
}
```

## `str.length` (function, overload 1)

**Definition**

Gives the length of a string as an int.

One argument, required. The length counts bytes of the text (UTF-8), not characters, so a character outside ASCII counts as two or more.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.length(const string source) → const int
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `const string` | yes | Source string. |

**Returns**

`const int`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Length Example", overlay=false)
tickerSymbol = syminfo.ticker
tickerLength = str.length(tickerSymbol)
plot(tickerLength, title="Ticker Length", color=color.blue)
```

## `str.length` (function, overload 2)

**Definition**

Gives the length of a string as an int.

One argument, required. The length counts bytes of the text (UTF-8), not characters, so a character outside ASCII counts as two or more.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.length(input string source) → input int
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `input string` | yes | Source string. |

**Returns**

`input int`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Length Example", overlay=false)
tickerSymbol = syminfo.ticker
tickerLength = str.length(tickerSymbol)
plot(tickerLength, title="Ticker Length", color=color.blue)
```

## `str.length` (function, overload 3)

**Definition**

Gives the length of a string as an int.

One argument, required. The length counts bytes of the text (UTF-8), not characters, so a character outside ASCII counts as two or more.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.length(simple string source) → simple int
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `simple string` | yes | Source string. |

**Returns**

`simple int`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Length Example", overlay=false)
tickerSymbol = syminfo.ticker
tickerLength = str.length(tickerSymbol)
plot(tickerLength, title="Ticker Length", color=color.blue)
```

## `str.length` (function, overload 4)

**Definition**

Gives the length of a string as an int.

One argument, required. The length counts bytes of the text (UTF-8), not characters, so a character outside ASCII counts as two or more.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.length(series string source) → series int
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `series string` | yes | Source string. |

**Returns**

`series int`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Length Example", overlay=false)
tickerSymbol = syminfo.ticker
tickerLength = str.length(tickerSymbol)
plot(tickerLength, title="Ticker Length", color=color.blue)
```

## `str.lower` (function, overload 1)

**Definition**

Converts a string to lower case.

It takes the string and nothing else.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.lower(const string source) → const string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `const string` | yes | String to be converted. |

**Returns**

`const string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("Lowercase Example", overlay=false)
tickerSymbol = syminfo.ticker
lowercaseTicker = str.lower(tickerSymbol)
isLowercase = tickerSymbol != lowercaseTicker
plot(isLowercase ? 1 : 0, title="Converted to Lowercase", color=color.blue)
```

## `str.lower` (function, overload 2)

**Definition**

Converts a string to lower case.

It takes the string and nothing else.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.lower(input string source) → input string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `input string` | yes | String to be converted. |

**Returns**

`input string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("Lowercase Example", overlay=false)
tickerSymbol = syminfo.ticker
lowercaseTicker = str.lower(tickerSymbol)
isLowercase = tickerSymbol != lowercaseTicker
plot(isLowercase ? 1 : 0, title="Converted to Lowercase", color=color.blue)
```

## `str.lower` (function, overload 3)

**Definition**

Converts a string to lower case.

It takes the string and nothing else.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.lower(simple string source) → simple string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `simple string` | yes | String to be converted. |

**Returns**

`simple string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("Lowercase Example", overlay=false)
tickerSymbol = syminfo.ticker
lowercaseTicker = str.lower(tickerSymbol)
isLowercase = tickerSymbol != lowercaseTicker
plot(isLowercase ? 1 : 0, title="Converted to Lowercase", color=color.blue)
```

## `str.lower` (function, overload 4)

**Definition**

Converts a string to lower case.

It takes the string and nothing else.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.lower(series string source) → series string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `series string` | yes | String to be converted. |

**Returns**

`series string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("Lowercase Example", overlay=false)
tickerSymbol = syminfo.ticker
lowercaseTicker = str.lower(tickerSymbol)
isLowercase = tickerSymbol != lowercaseTicker
plot(isLowercase ? 1 : 0, title="Converted to Lowercase", color=color.blue)
```

## `str.match` (function, overload 1)

**Definition**

Returns the first part of `source` that matches the regular expression `pattern`.

Patterns are written in RE2 syntax, which has no backreferences and no lookaround. A pattern that will not compile is not an error: the call returns empty text.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.match(const string source, const string pattern) → const string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `const string` | yes | Source string. |
| `pattern` | `const string` | yes | The regular expression to which this string is to be matched. |

**Returns**

`const string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.match Example", overlay=false)
string orderText = "order-4521-shipped"
string digits = str.match(orderText, "[0-9]+")
string capitals = str.match(orderText, "[A-Z]+")
plot(str.length(digits), title="Length of the match")
plot(str.length(capitals), title="Length when nothing matches")
```

## `str.match` (function, overload 2)

**Definition**

Returns the first part of `source` that matches the regular expression `pattern`.

Patterns are written in RE2 syntax, which has no backreferences and no lookaround. A pattern that will not compile is not an error: the call returns empty text.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.match(input string source, input string pattern) → input string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `input string` | yes | Source string. |
| `pattern` | `input string` | yes | The regular expression to which this string is to be matched. |

**Returns**

`input string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.match Example", overlay=false)
string orderText = "order-4521-shipped"
string digits = str.match(orderText, "[0-9]+")
string capitals = str.match(orderText, "[A-Z]+")
plot(str.length(digits), title="Length of the match")
plot(str.length(capitals), title="Length when nothing matches")
```

## `str.match` (function, overload 3)

**Definition**

Returns the first part of `source` that matches the regular expression `pattern`.

Patterns are written in RE2 syntax, which has no backreferences and no lookaround. A pattern that will not compile is not an error: the call returns empty text.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.match(simple string source, simple string pattern) → simple string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `simple string` | yes | Source string. |
| `pattern` | `simple string` | yes | The regular expression to which this string is to be matched. |

**Returns**

`simple string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.match Example", overlay=false)
string orderText = "order-4521-shipped"
string digits = str.match(orderText, "[0-9]+")
string capitals = str.match(orderText, "[A-Z]+")
plot(str.length(digits), title="Length of the match")
plot(str.length(capitals), title="Length when nothing matches")
```

## `str.match` (function, overload 4)

**Definition**

Returns the first part of `source` that matches the regular expression `pattern`.

Patterns are written in RE2 syntax, which has no backreferences and no lookaround. A pattern that will not compile is not an error: the call returns empty text.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.match(series string source, series string pattern) → series string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `series string` | yes | Source string. |
| `pattern` | `series string` | yes | The regular expression to which this string is to be matched. |

**Returns**

`series string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.match Example", overlay=false)
string orderText = "order-4521-shipped"
string digits = str.match(orderText, "[0-9]+")
string capitals = str.match(orderText, "[A-Z]+")
plot(str.length(digits), title="Length of the match")
plot(str.length(capitals), title="Length when nothing matches")
```

## `str.pos` (function, overload 1)

**Definition**

Reports the position at which one string sits inside another.

The result is an int: the position of the first match, counted in bytes from 0, or -1 when `str` does not occur in `source`. For text outside ASCII a byte position is not a character position, so a result of `str.pos` passed to `str.substring`, which counts characters, can cut at the wrong place.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.pos(const string source, const string str) → const int
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `const string` | yes | Source string. |
| `str` | `const string` | yes | The substring to search for. |

**Returns**

`const int`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.pos Example", overlay=true)
// Show where "USD" appears in the ticker
if barstate.islast {
    label.new(bar_index, high, text="USD at position " + str.tostring(str.pos(syminfo.ticker, "USD")))
}
```

## `str.pos` (function, overload 2)

**Definition**

Reports the position at which one string sits inside another.

The result is an int: the position of the first match, counted in bytes from 0, or -1 when `str` does not occur in `source`. For text outside ASCII a byte position is not a character position, so a result of `str.pos` passed to `str.substring`, which counts characters, can cut at the wrong place.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.pos(input string source, input string str) → input int
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `input string` | yes | Source string. |
| `str` | `input string` | yes | The substring to search for. |

**Returns**

`input int`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.pos Example", overlay=true)
// Show where "USD" appears in the ticker
if barstate.islast {
    label.new(bar_index, high, text="USD at position " + str.tostring(str.pos(syminfo.ticker, "USD")))
}
```

## `str.pos` (function, overload 3)

**Definition**

Reports the position at which one string sits inside another.

The result is an int: the position of the first match, counted in bytes from 0, or -1 when `str` does not occur in `source`. For text outside ASCII a byte position is not a character position, so a result of `str.pos` passed to `str.substring`, which counts characters, can cut at the wrong place.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.pos(simple string source, simple string str) → simple int
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `simple string` | yes | Source string. |
| `str` | `simple string` | yes | The substring to search for. |

**Returns**

`simple int`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.pos Example", overlay=true)
// Show where "USD" appears in the ticker
if barstate.islast {
    label.new(bar_index, high, text="USD at position " + str.tostring(str.pos(syminfo.ticker, "USD")))
}
```

## `str.pos` (function, overload 4)

**Definition**

Reports the position at which one string sits inside another.

The result is an int: the position of the first match, counted in bytes from 0, or -1 when `str` does not occur in `source`. For text outside ASCII a byte position is not a character position, so a result of `str.pos` passed to `str.substring`, which counts characters, can cut at the wrong place.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.pos(series string source, series string str) → series int
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `series string` | yes | Source string. |
| `str` | `series string` | yes | The substring to search for. |

**Returns**

`series int`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.pos Example", overlay=true)
// Show where "USD" appears in the ticker
if barstate.islast {
    label.new(bar_index, high, text="USD at position " + str.tostring(str.pos(syminfo.ticker, "USD")))
}
```

## `str.repeat` (function, overload 1)

**Definition**

Produces a string made of repeated copies of another, with the option of something between the copies.

The string and the count are required; the separator is not.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.repeat(const string source, const int count, const string separator) → const string
```

**Parameters**

| Name | Type | Required | Description | Default |
| - | - | - | - | - |
| `source` | `const string` | yes | String to repeat. | |
| `count` | `const int` | yes | Number of times to repeat the source string. Must be greater than or equal to 0. | |
| `separator` | `const string` | no | String to inject between repeated values. Optional. The default is empty string. | `""` |

**Returns**

`const string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Repeat Example", overlay=false)
str1 = "GoCharting"
repeatedStr = str.repeat(str1, 3)
plot(close, title=repeatedStr)
```

## `str.repeat` (function, overload 2)

**Definition**

Produces a string made of repeated copies of another, with the option of something between the copies.

The string and the count are required; the separator is not.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.repeat(input string source, input int count, input string separator) → input string
```

**Parameters**

| Name | Type | Required | Description | Default |
| - | - | - | - | - |
| `source` | `input string` | yes | String to repeat. | |
| `count` | `input int` | yes | Number of times to repeat the source string. Must be greater than or equal to 0. | |
| `separator` | `input string` | no | String to inject between repeated values. Optional. The default is empty string. | `""` |

**Returns**

`input string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Repeat Example", overlay=false)
str1 = "GoCharting"
repeatedStr = str.repeat(str1, 3)
plot(close, title=repeatedStr)
```

## `str.repeat` (function, overload 3)

**Definition**

Produces a string made of repeated copies of another, with the option of something between the copies.

The string and the count are required; the separator is not.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.repeat(simple string source, simple int count, simple string separator) → simple string
```

**Parameters**

| Name | Type | Required | Description | Default |
| - | - | - | - | - |
| `source` | `simple string` | yes | String to repeat. | |
| `count` | `simple int` | yes | Number of times to repeat the source string. Must be greater than or equal to 0. | |
| `separator` | `simple string` | no | String to inject between repeated values. Optional. The default is empty string. | `""` |

**Returns**

`simple string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Repeat Example", overlay=false)
str1 = "GoCharting"
repeatedStr = str.repeat(str1, 3)
plot(close, title=repeatedStr)
```

## `str.repeat` (function, overload 4)

**Definition**

Produces a string made of repeated copies of another, with the option of something between the copies.

The string and the count are required; the separator is not.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.repeat(series string source, series int count, series string separator) → series string
```

**Parameters**

| Name | Type | Required | Description | Default |
| - | - | - | - | - |
| `source` | `series string` | yes | String to repeat. | |
| `count` | `series int` | yes | Number of times to repeat the source string. Must be greater than or equal to 0. | |
| `separator` | `series string` | no | String to inject between repeated values. Optional. The default is empty string. | `""` |

**Returns**

`series string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Repeat Example", overlay=false)
str1 = "GoCharting"
repeatedStr = str.repeat(str1, 3)
plot(close, title=repeatedStr)
```

## `str.replace` (function, overload 1)

**Definition**

Substitutes one piece of text for another inside a string.

The source, the old text and the new text are required; the count is optional.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.replace(const string source, const string old, const string new, const int count) → const string
```

**Parameters**

| Name | Type | Required | Description | Default |
| - | - | - | - | - |
| `source` | `const string` | yes | Source string. | |
| `old` | `const string` | yes | String to be replaced. | |
| `new` | `const string` | yes | String to be inserted in place of `old`. | |
| `count` | `const int` | no | Maximum number of replacements, counted from the start of the string. Optional. The default is -1, which replaces every occurrence. | `-1` |

**Returns**

`const string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator(str.replace("GoCharting is great!", "great", "awesome"), overlay=false)
plot(close)
```

## `str.replace` (function, overload 2)

**Definition**

Substitutes one piece of text for another inside a string.

The source, the old text and the new text are required; the count is optional.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.replace(input string source, input string old, input string new, input int count) → input string
```

**Parameters**

| Name | Type | Required | Description | Default |
| - | - | - | - | - |
| `source` | `input string` | yes | Source string. | |
| `old` | `input string` | yes | String to be replaced. | |
| `new` | `input string` | yes | String to be inserted in place of `old`. | |
| `count` | `input int` | no | Maximum number of replacements, counted from the start of the string. Optional. The default is -1, which replaces every occurrence. | `-1` |

**Returns**

`input string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator(str.replace("GoCharting is great!", "great", "awesome"), overlay=false)
plot(close)
```

## `str.replace` (function, overload 3)

**Definition**

Substitutes one piece of text for another inside a string.

The source, the old text and the new text are required; the count is optional.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.replace(simple string source, simple string old, simple string new, simple int count) → simple string
```

**Parameters**

| Name | Type | Required | Description | Default |
| - | - | - | - | - |
| `source` | `simple string` | yes | Source string. | |
| `old` | `simple string` | yes | String to be replaced. | |
| `new` | `simple string` | yes | String to be inserted in place of `old`. | |
| `count` | `simple int` | no | Maximum number of replacements, counted from the start of the string. Optional. The default is -1, which replaces every occurrence. | `-1` |

**Returns**

`simple string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator(str.replace("GoCharting is great!", "great", "awesome"), overlay=false)
plot(close)
```

## `str.replace` (function, overload 4)

**Definition**

Substitutes one piece of text for another inside a string.

The source, the old text and the new text are required; the count is optional.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.replace(series string source, series string old, series string new, series int count) → series string
```

**Parameters**

| Name | Type | Required | Description | Default |
| - | - | - | - | - |
| `source` | `series string` | yes | Source string. | |
| `old` | `series string` | yes | String to be replaced. | |
| `new` | `series string` | yes | String to be inserted in place of `old`. | |
| `count` | `series int` | no | Maximum number of replacements, counted from the start of the string. Optional. The default is -1, which replaces every occurrence. | `-1` |

**Returns**

`series string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator(str.replace("GoCharting is great!", "great", "awesome"), overlay=false)
plot(close)
```

## `str.replace_all` (function, overload 1)

**Definition**

Substitutes new text for every occurrence of the old text.

It takes no count. That is the difference between it and str.replace, which does.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.replace_all(const string source, const string old, const string new) → const string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `const string` | yes | Source string. |
| `old` | `const string` | yes | Text to look for: every occurrence of it in `source` is replaced. |
| `new` | `const string` | yes | Text that replaces each occurrence of `old`. |

**Returns**

`const string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator(str.replace_all("GoCharting is great and GoCharting is powerful!", "Chart",  "view"), overlay=false)
plot(close)
```

## `str.replace_all` (function, overload 2)

**Definition**

Substitutes new text for every occurrence of the old text.

It takes no count. That is the difference between it and str.replace, which does.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.replace_all(input string source, input string old, input string new) → input string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `input string` | yes | Source string. |
| `old` | `input string` | yes | Text to look for: every occurrence of it in `source` is replaced. |
| `new` | `input string` | yes | Text that replaces each occurrence of `old`. |

**Returns**

`input string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator(str.replace_all("GoCharting is great and GoCharting is powerful!", "Chart",  "view"), overlay=false)
plot(close)
```

## `str.replace_all` (function, overload 3)

**Definition**

Substitutes new text for every occurrence of the old text.

It takes no count. That is the difference between it and str.replace, which does.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.replace_all(simple string source, simple string old, simple string new) → simple string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `simple string` | yes | Source string. |
| `old` | `simple string` | yes | Text to look for: every occurrence of it in `source` is replaced. |
| `new` | `simple string` | yes | Text that replaces each occurrence of `old`. |

**Returns**

`simple string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator(str.replace_all("GoCharting is great and GoCharting is powerful!", "Chart",  "view"), overlay=false)
plot(close)
```

## `str.replace_all` (function, overload 4)

**Definition**

Substitutes new text for every occurrence of the old text.

It takes no count. That is the difference between it and str.replace, which does.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.replace_all(series string source, series string old, series string new) → series string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `series string` | yes | Source string. |
| `old` | `series string` | yes | Text to look for: every occurrence of it in `source` is replaced. |
| `new` | `series string` | yes | Text that replaces each occurrence of `old`. |

**Returns**

`series string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator(str.replace_all("GoCharting is great and GoCharting is powerful!", "Chart",  "view"), overlay=false)
plot(close)
```

## `str.split` (function, overload 1)

**Definition**

Splits `string` wherever `separator` occurs and returns the pieces as an array of strings. The separator itself is not included in the pieces.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.split(const string string, const string separator) → series array<string>
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `string` | `const string` | yes | String to split. |
| `separator` | `const string` | yes | The string at which `string` is split. |

**Returns**

`series array<string>`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.split Example", overlay=true)
parts = str.split("10,20,30", ",")
if barstate.islast {
    label.new(bar_index, high, text="Pieces: " + str.tostring(array.length(parts)))
}
```

## `str.split` (function, overload 2)

**Definition**

Splits `string` wherever `separator` occurs and returns the pieces as an array of strings. The separator itself is not included in the pieces.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.split(input string string, input string separator) → series array<string>
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `string` | `input string` | yes | String to split. |
| `separator` | `input string` | yes | The string at which `string` is split. |

**Returns**

`series array<string>`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.split Example", overlay=true)
parts = str.split("10,20,30", ",")
if barstate.islast {
    label.new(bar_index, high, text="Pieces: " + str.tostring(array.length(parts)))
}
```

## `str.split` (function, overload 3)

**Definition**

Splits `string` wherever `separator` occurs and returns the pieces as an array of strings. The separator itself is not included in the pieces.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.split(simple string string, simple string separator) → series array<string>
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `string` | `simple string` | yes | String to split. |
| `separator` | `simple string` | yes | The string at which `string` is split. |

**Returns**

`series array<string>`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.split Example", overlay=true)
parts = str.split("10,20,30", ",")
if barstate.islast {
    label.new(bar_index, high, text="Pieces: " + str.tostring(array.length(parts)))
}
```

## `str.split` (function, overload 4)

**Definition**

Splits `string` wherever `separator` occurs and returns the pieces as an array of strings. The separator itself is not included in the pieces.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.split(series string string, series string separator) → series array<string>
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `string` | `series string` | yes | String to split. |
| `separator` | `series string` | yes | The string at which `string` is split. |

**Returns**

`series array<string>`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.split Example", overlay=true)
parts = str.split("10,20,30", ",")
if barstate.islast {
    label.new(bar_index, high, text="Pieces: " + str.tostring(array.length(parts)))
}
```

## `str.startswith` (function, overload 1)

**Definition**

The counterpart of str.endswith, looking at the front of the string instead of the back.

Both arguments are required.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.startswith(const string source, const string prefix) → const bool
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `const string` | yes | Source string. |
| `prefix` | `const string` | yes | The substring to search for. |

**Returns**

`const bool`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String StartsWith Example", overlay=false)
myStr = "GoCharting is awesome!"
doesStart = str.startswith(myStr, "GoCharting")
plot(doesStart ? 1 : 0, title="Starts with 'GoCharting'")
```

## `str.startswith` (function, overload 2)

**Definition**

The counterpart of str.endswith, looking at the front of the string instead of the back.

Both arguments are required.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.startswith(input string source, input string prefix) → input bool
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `input string` | yes | Source string. |
| `prefix` | `input string` | yes | The substring to search for. |

**Returns**

`input bool`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String StartsWith Example", overlay=false)
myStr = "GoCharting is awesome!"
doesStart = str.startswith(myStr, "GoCharting")
plot(doesStart ? 1 : 0, title="Starts with 'GoCharting'")
```

## `str.startswith` (function, overload 3)

**Definition**

The counterpart of str.endswith, looking at the front of the string instead of the back.

Both arguments are required.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.startswith(simple string source, simple string prefix) → simple bool
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `simple string` | yes | Source string. |
| `prefix` | `simple string` | yes | The substring to search for. |

**Returns**

`simple bool`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String StartsWith Example", overlay=false)
myStr = "GoCharting is awesome!"
doesStart = str.startswith(myStr, "GoCharting")
plot(doesStart ? 1 : 0, title="Starts with 'GoCharting'")
```

## `str.startswith` (function, overload 4)

**Definition**

The counterpart of str.endswith, looking at the front of the string instead of the back.

Both arguments are required.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.startswith(series string source, series string prefix) → series bool
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `series string` | yes | Source string. |
| `prefix` | `series string` | yes | The substring to search for. |

**Returns**

`series bool`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String StartsWith Example", overlay=false)
myStr = "GoCharting is awesome!"
doesStart = str.startswith(myStr, "GoCharting")
plot(doesStart ? 1 : 0, title="Starts with 'GoCharting'")
```

## `str.substring` (function, overload 1)

**Definition**

Cuts a piece out of a string. There are two forms: one takes a start and an end, the other takes a start alone.

Positions are ints, counted in characters from 0, not in bytes. `start` is inclusive and `end` is exclusive. Without `end`, the result runs to the end of `source`. A `start` at or beyond the end of the text gives an empty string, and an `end` beyond it stops at the end. With `end`, a negative `start` or `end`, or an `end` before `start`, is refused with the error "Invalid argument passed to Subsctring" by the check that runs when the script is added to the chart (the editor's check does not report it); on a later bar the same invalid range gives `na`. Without `end`, a negative `start` gives an empty string.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.substring(const string source, const int start, const int end) → const string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `const string` | yes | Source string from which to extract the substring. |
| `start` | `const int` | yes | The beginning position of the extracted substring. It is inclusive (the extracted substring includes the character at that position). |
| `end` | `const int` | yes | The ending position. It is exclusive (the extracted string does not include the character at that position). |

**Returns**

`const string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Substring Example", overlay=false)
myStr = "GoCharting is powerful"
subStr = str.substring(myStr, 0, 10)
plot(close, title=subStr)
```

## `str.substring` (function, overload 2)

**Definition**

Cuts a piece out of a string. There are two forms: one takes a start and an end, the other takes a start alone.

Positions are ints, counted in characters from 0, not in bytes. `start` is inclusive and `end` is exclusive. Without `end`, the result runs to the end of `source`. A `start` at or beyond the end of the text gives an empty string, and an `end` beyond it stops at the end. With `end`, a negative `start` or `end`, or an `end` before `start`, is refused with the error "Invalid argument passed to Subsctring" by the check that runs when the script is added to the chart (the editor's check does not report it); on a later bar the same invalid range gives `na`. Without `end`, a negative `start` gives an empty string.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.substring(input string source, input int start, input int end) → input string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `input string` | yes | Source string from which to extract the substring. |
| `start` | `input int` | yes | The beginning position of the extracted substring. It is inclusive (the extracted substring includes the character at that position). |
| `end` | `input int` | yes | The ending position. It is exclusive (the extracted string does not include the character at that position). |

**Returns**

`input string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Substring Example", overlay=false)
myStr = "GoCharting is powerful"
subStr = str.substring(myStr, 0, 10)
plot(close, title=subStr)
```

## `str.substring` (function, overload 3)

**Definition**

Cuts a piece out of a string. There are two forms: one takes a start and an end, the other takes a start alone.

Positions are ints, counted in characters from 0, not in bytes. `start` is inclusive and `end` is exclusive. Without `end`, the result runs to the end of `source`. A `start` at or beyond the end of the text gives an empty string, and an `end` beyond it stops at the end. With `end`, a negative `start` or `end`, or an `end` before `start`, is refused with the error "Invalid argument passed to Subsctring" by the check that runs when the script is added to the chart (the editor's check does not report it); on a later bar the same invalid range gives `na`. Without `end`, a negative `start` gives an empty string.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.substring(simple string source, simple int start, simple int end) → simple string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `simple string` | yes | Source string from which to extract the substring. |
| `start` | `simple int` | yes | The beginning position of the extracted substring. It is inclusive (the extracted substring includes the character at that position). |
| `end` | `simple int` | yes | The ending position. It is exclusive (the extracted string does not include the character at that position). |

**Returns**

`simple string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Substring Example", overlay=false)
myStr = "GoCharting is powerful"
subStr = str.substring(myStr, 0, 10)
plot(close, title=subStr)
```

## `str.substring` (function, overload 4)

**Definition**

Cuts a piece out of a string. There are two forms: one takes a start and an end, the other takes a start alone.

Positions are ints, counted in characters from 0, not in bytes. `start` is inclusive and `end` is exclusive. Without `end`, the result runs to the end of `source`. A `start` at or beyond the end of the text gives an empty string, and an `end` beyond it stops at the end. With `end`, a negative `start` or `end`, or an `end` before `start`, is refused with the error "Invalid argument passed to Subsctring" by the check that runs when the script is added to the chart (the editor's check does not report it); on a later bar the same invalid range gives `na`. Without `end`, a negative `start` gives an empty string.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.substring(series string source, series int start, series int end) → series string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `series string` | yes | Source string from which to extract the substring. |
| `start` | `series int` | yes | The beginning position of the extracted substring. It is inclusive (the extracted substring includes the character at that position). |
| `end` | `series int` | yes | The ending position. It is exclusive (the extracted string does not include the character at that position). |

**Returns**

`series string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Substring Example", overlay=false)
myStr = "GoCharting is powerful"
subStr = str.substring(myStr, 0, 10)
plot(close, title=subStr)
```

## `str.substring` (function, overload 5)

**Definition**

Cuts a piece out of a string. There are two forms: one takes a start and an end, the other takes a start alone.

Positions are ints, counted in characters from 0, not in bytes. `start` is inclusive and `end` is exclusive. Without `end`, the result runs to the end of `source`. A `start` at or beyond the end of the text gives an empty string, and an `end` beyond it stops at the end. With `end`, a negative `start` or `end`, or an `end` before `start`, is refused with the error "Invalid argument passed to Subsctring" by the check that runs when the script is added to the chart (the editor's check does not report it); on a later bar the same invalid range gives `na`. Without `end`, a negative `start` gives an empty string.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.substring(const string source, const int start) → const string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `const string` | yes | Source string from which to extract the substring. |
| `start` | `const int` | yes | The beginning position of the extracted substring. It is inclusive (the extracted substring includes the character at that position). |

**Returns**

`const string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Substring Example", overlay=false)
myStr = "GoCharting is powerful"
subStr = str.substring(myStr, 0, 10)
plot(close, title=subStr)
```

## `str.substring` (function, overload 6)

**Definition**

Cuts a piece out of a string. There are two forms: one takes a start and an end, the other takes a start alone.

Positions are ints, counted in characters from 0, not in bytes. `start` is inclusive and `end` is exclusive. Without `end`, the result runs to the end of `source`. A `start` at or beyond the end of the text gives an empty string, and an `end` beyond it stops at the end. With `end`, a negative `start` or `end`, or an `end` before `start`, is refused with the error "Invalid argument passed to Subsctring" by the check that runs when the script is added to the chart (the editor's check does not report it); on a later bar the same invalid range gives `na`. Without `end`, a negative `start` gives an empty string.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.substring(input string source, input int start) → input string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `input string` | yes | Source string from which to extract the substring. |
| `start` | `input int` | yes | The beginning position of the extracted substring. It is inclusive (the extracted substring includes the character at that position). |

**Returns**

`input string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Substring Example", overlay=false)
myStr = "GoCharting is powerful"
subStr = str.substring(myStr, 0, 10)
plot(close, title=subStr)
```

## `str.substring` (function, overload 7)

**Definition**

Cuts a piece out of a string. There are two forms: one takes a start and an end, the other takes a start alone.

Positions are ints, counted in characters from 0, not in bytes. `start` is inclusive and `end` is exclusive. Without `end`, the result runs to the end of `source`. A `start` at or beyond the end of the text gives an empty string, and an `end` beyond it stops at the end. With `end`, a negative `start` or `end`, or an `end` before `start`, is refused with the error "Invalid argument passed to Subsctring" by the check that runs when the script is added to the chart (the editor's check does not report it); on a later bar the same invalid range gives `na`. Without `end`, a negative `start` gives an empty string.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.substring(simple string source, simple int start) → simple string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `simple string` | yes | Source string from which to extract the substring. |
| `start` | `simple int` | yes | The beginning position of the extracted substring. It is inclusive (the extracted substring includes the character at that position). |

**Returns**

`simple string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Substring Example", overlay=false)
myStr = "GoCharting is powerful"
subStr = str.substring(myStr, 0, 10)
plot(close, title=subStr)
```

## `str.substring` (function, overload 8)

**Definition**

Cuts a piece out of a string. There are two forms: one takes a start and an end, the other takes a start alone.

Positions are ints, counted in characters from 0, not in bytes. `start` is inclusive and `end` is exclusive. Without `end`, the result runs to the end of `source`. A `start` at or beyond the end of the text gives an empty string, and an `end` beyond it stops at the end. With `end`, a negative `start` or `end`, or an `end` before `start`, is refused with the error "Invalid argument passed to Subsctring" by the check that runs when the script is added to the chart (the editor's check does not report it); on a later bar the same invalid range gives `na`. Without `end`, a negative `start` gives an empty string.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.substring(series string source, series int start) → series string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `series string` | yes | Source string from which to extract the substring. |
| `start` | `series int` | yes | The beginning position of the extracted substring. It is inclusive (the extracted substring includes the character at that position). |

**Returns**

`series string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Substring Example", overlay=false)
myStr = "GoCharting is powerful"
subStr = str.substring(myStr, 0, 10)
plot(close, title=subStr)
```

## `str.tonumber` (function, overload 1)

**Definition**

Reads a number out of a string.

The result is a float in every form, so a string holding a whole number still comes back as a float.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.tonumber(const string source) → const float
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `const string` | yes | String containing the representation of an integer or floating point value. |

**Returns**

`const float`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String to Number Example", overlay=false)
numStr1 = "123.45"
numStr2 = "456"
num1 = str.tonumber(numStr1)
num2 = str.tonumber(numStr2)
plot(num1, title="Converted Number 1")
plot(num2, title="Converted Number 2")
```

## `str.tonumber` (function, overload 2)

**Definition**

Reads a number out of a string.

The result is a float in every form, so a string holding a whole number still comes back as a float.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.tonumber(input string source) → input float
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `input string` | yes | String containing the representation of an integer or floating point value. |

**Returns**

`input float`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String to Number Example", overlay=false)
numStr1 = "123.45"
numStr2 = "456"
num1 = str.tonumber(numStr1)
num2 = str.tonumber(numStr2)
plot(num1, title="Converted Number 1")
plot(num2, title="Converted Number 2")
```

## `str.tonumber` (function, overload 3)

**Definition**

Reads a number out of a string.

The result is a float in every form, so a string holding a whole number still comes back as a float.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.tonumber(simple string source) → simple float
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `simple string` | yes | String containing the representation of an integer or floating point value. |

**Returns**

`simple float`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String to Number Example", overlay=false)
numStr1 = "123.45"
numStr2 = "456"
num1 = str.tonumber(numStr1)
num2 = str.tonumber(numStr2)
plot(num1, title="Converted Number 1")
plot(num2, title="Converted Number 2")
```

## `str.tonumber` (function, overload 4)

**Definition**

Reads a number out of a string.

The result is a float in every form, so a string holding a whole number still comes back as a float.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.tonumber(series string source) → series float
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `series string` | yes | String containing the representation of an integer or floating point value. |

**Returns**

`series float`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String to Number Example", overlay=false)
numStr1 = "123.45"
numStr2 = "456"
num1 = str.tonumber(numStr1)
num2 = str.tonumber(numStr2)
plot(num1, title="Converted Number 1")
plot(num2, title="Converted Number 2")
```

## `str.tostring` (function, overload 1)

**Definition**

Renders a value as a string.

Overload on `float` or `bool` alone: a float is rounded to 4 decimal places and trailing zeros are trimmed, so a smaller difference is lost (`0.00004` gives `0`); to keep more digits, use the overload with `format`, for example `str.tostring(price, "#.########")`. Bools become `true` or `false`; `na` becomes `"NA"`.

Overload on `float` with `format` (and optional `mintick`): supports `mintick`, `volume`, and `percent`, plus custom patterns made of `#` and `0` (for example `#.##`). Default format is `#.##########`.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.tostring(simple float source) → simple string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `simple float` | yes | Value to convert (`float` or `bool` depending on overload). |

**Returns**

`simple string`

String representation of the input.

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.tostring Example", overlay=true)
if barstate.islast {
    label.new(bar_index, high, text="Vol: " + str.tostring(volume, format.volume))
    label.new(bar_index, low, text="Tick: " + str.tostring(close, format.mintick), style=label.style_label_up)
}
```

## `str.tostring` (function, overload 2)

**Definition**

Renders a value as a string.

Overload on `float` or `bool` alone: a float is rounded to 4 decimal places and trailing zeros are trimmed, so a smaller difference is lost (`0.00004` gives `0`); to keep more digits, use the overload with `format`, for example `str.tostring(price, "#.########")`. Bools become `true` or `false`; `na` becomes `"NA"`.

Overload on `float` with `format` (and optional `mintick`): supports `mintick`, `volume`, and `percent`, plus custom patterns made of `#` and `0` (for example `#.##`). Default format is `#.##########`.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.tostring(series float source) → series string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `series float` | yes | Value to convert (`float` or `bool` depending on overload). |

**Returns**

`series string`

String representation of the input.

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.tostring Example", overlay=true)
if barstate.islast {
    label.new(bar_index, high, text="Vol: " + str.tostring(volume, format.volume))
    label.new(bar_index, low, text="Tick: " + str.tostring(close, format.mintick), style=label.style_label_up)
}
```

## `str.tostring` (function, overload 3)

**Definition**

Renders a value as a string.

Overload on `float` or `bool` alone: a float is rounded to 4 decimal places and trailing zeros are trimmed, so a smaller difference is lost (`0.00004` gives `0`); to keep more digits, use the overload with `format`, for example `str.tostring(price, "#.########")`. Bools become `true` or `false`; `na` becomes `"NA"`.

Overload on `float` with `format` (and optional `mintick`): supports `mintick`, `volume`, and `percent`, plus custom patterns made of `#` and `0` (for example `#.##`). Default format is `#.##########`.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.tostring(simple float value, simple string format, simple float mintick) → simple string
```

**Parameters**

| Name | Type | Required | Description | Default |
| - | - | - | - | - |
| `value` | `simple float` | yes | Float to format when using the two- or three-argument overload (`value`, `format`, optional `mintick`). | |
| `format` | `simple string` | no | Format name or pattern for the float overload: `format.mintick`, `format.volume`, `format.percent`, a `#`/`0` pattern, or the default `#.##########`. | `"#.##########"` |
| `mintick` | `simple float` | no | Tick size used when `format` is `format.mintick`. Defaults to `syminfo.mintick` when omitted. | `syminfo.mintick` |

**Returns**

`simple string`

String representation of the input.

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.tostring Example", overlay=true)
if barstate.islast {
    label.new(bar_index, high, text="Vol: " + str.tostring(volume, format.volume))
    label.new(bar_index, low, text="Tick: " + str.tostring(close, format.mintick), style=label.style_label_up)
}
```

## `str.tostring` (function, overload 4)

**Definition**

Renders a value as a string.

Overload on `float` or `bool` alone: a float is rounded to 4 decimal places and trailing zeros are trimmed, so a smaller difference is lost (`0.00004` gives `0`); to keep more digits, use the overload with `format`, for example `str.tostring(price, "#.########")`. Bools become `true` or `false`; `na` becomes `"NA"`.

Overload on `float` with `format` (and optional `mintick`): supports `mintick`, `volume`, and `percent`, plus custom patterns made of `#` and `0` (for example `#.##`). Default format is `#.##########`.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.tostring(series float value, series string format, simple float mintick) → series string
```

**Parameters**

| Name | Type | Required | Description | Default |
| - | - | - | - | - |
| `value` | `series float` | yes | Float to format when using the two- or three-argument overload (`value`, `format`, optional `mintick`). | |
| `format` | `series string` | no | Format name or pattern for the float overload: `format.mintick`, `format.volume`, `format.percent`, a `#`/`0` pattern, or the default `#.##########`. | `"#.##########"` |
| `mintick` | `simple float` | no | Tick size used when `format` is `format.mintick`. Defaults to `syminfo.mintick` when omitted. | `syminfo.mintick` |

**Returns**

`series string`

String representation of the input.

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.tostring Example", overlay=true)
if barstate.islast {
    label.new(bar_index, high, text="Vol: " + str.tostring(volume, format.volume))
    label.new(bar_index, low, text="Tick: " + str.tostring(close, format.mintick), style=label.style_label_up)
}
```

## `str.tostring` (function, overload 5)

**Definition**

Renders a value as a string.

Overload on `float` or `bool` alone: a float is rounded to 4 decimal places and trailing zeros are trimmed, so a smaller difference is lost (`0.00004` gives `0`); to keep more digits, use the overload with `format`, for example `str.tostring(price, "#.########")`. Bools become `true` or `false`; `na` becomes `"NA"`.

Overload on `float` with `format` (and optional `mintick`): supports `mintick`, `volume`, and `percent`, plus custom patterns made of `#` and `0` (for example `#.##`). Default format is `#.##########`.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.tostring(simple bool source) → simple string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `simple bool` | yes | Value to convert (`float` or `bool` depending on overload). |

**Returns**

`simple string`

String representation of the input.

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.tostring Example", overlay=true)
if barstate.islast {
    label.new(bar_index, high, text="Vol: " + str.tostring(volume, format.volume))
    label.new(bar_index, low, text="Tick: " + str.tostring(close, format.mintick), style=label.style_label_up)
}
```

## `str.tostring` (function, overload 6)

**Definition**

Renders a value as a string.

Overload on `float` or `bool` alone: a float is rounded to 4 decimal places and trailing zeros are trimmed, so a smaller difference is lost (`0.00004` gives `0`); to keep more digits, use the overload with `format`, for example `str.tostring(price, "#.########")`. Bools become `true` or `false`; `na` becomes `"NA"`.

Overload on `float` with `format` (and optional `mintick`): supports `mintick`, `volume`, and `percent`, plus custom patterns made of `#` and `0` (for example `#.##`). Default format is `#.##########`.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.tostring(series bool source) → series string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `series bool` | yes | Value to convert (`float` or `bool` depending on overload). |

**Returns**

`series string`

String representation of the input.

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.tostring Example", overlay=true)
if barstate.islast {
    label.new(bar_index, high, text="Vol: " + str.tostring(volume, format.volume))
    label.new(bar_index, low, text="Tick: " + str.tostring(close, format.mintick), style=label.style_label_up)
}
```

## `str.trim` (function, overload 1)

**Definition**

Removes whitespace from around a string and hands back the result.

It removes the white space that Unicode defines at both ends: spaces, tabs, line breaks and the other characters Unicode marks as white space.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.trim(const string source) → const string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `const string` | yes | String to trim. |

**Returns**

`const string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Trim Example", overlay=false)
strWithSpaces = "GoCharting"
trimmedStr = str.trim(strWithSpaces)
plot(close, title=trimmedStr)
```

## `str.trim` (function, overload 2)

**Definition**

Removes whitespace from around a string and hands back the result.

It removes the white space that Unicode defines at both ends: spaces, tabs, line breaks and the other characters Unicode marks as white space.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.trim(input string source) → input string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `input string` | yes | String to trim. |

**Returns**

`input string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Trim Example", overlay=false)
strWithSpaces = "GoCharting"
trimmedStr = str.trim(strWithSpaces)
plot(close, title=trimmedStr)
```

## `str.trim` (function, overload 3)

**Definition**

Removes whitespace from around a string and hands back the result.

It removes the white space that Unicode defines at both ends: spaces, tabs, line breaks and the other characters Unicode marks as white space.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.trim(simple string source) → simple string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `simple string` | yes | String to trim. |

**Returns**

`simple string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Trim Example", overlay=false)
strWithSpaces = "GoCharting"
trimmedStr = str.trim(strWithSpaces)
plot(close, title=trimmedStr)
```

## `str.trim` (function, overload 4)

**Definition**

Removes whitespace from around a string and hands back the result.

It removes the white space that Unicode defines at both ends: spaces, tabs, line breaks and the other characters Unicode marks as white space.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.trim(series string source) → series string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `series string` | yes | String to trim. |

**Returns**

`series string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("String Trim Example", overlay=false)
strWithSpaces = "GoCharting"
trimmedStr = str.trim(strWithSpaces)
plot(close, title=trimmedStr)
```

## `str.upper` (function, overload 1)

**Definition**

Converts a string to upper case; the other half of the pair with str.lower.

It takes the string and nothing else.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.upper(const string source) → const string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `const string` | yes | String to be converted. |

**Returns**

`const string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.upper Example", overlay=true)
if barstate.islast {
    label.new(bar_index, high, text=str.upper(syminfo.ticker))
}
```

## `str.upper` (function, overload 2)

**Definition**

Converts a string to upper case; the other half of the pair with str.lower.

It takes the string and nothing else.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.upper(input string source) → input string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `input string` | yes | String to be converted. |

**Returns**

`input string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.upper Example", overlay=true)
if barstate.islast {
    label.new(bar_index, high, text=str.upper(syminfo.ticker))
}
```

## `str.upper` (function, overload 3)

**Definition**

Converts a string to upper case; the other half of the pair with str.lower.

It takes the string and nothing else.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.upper(simple string source) → simple string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `simple string` | yes | String to be converted. |

**Returns**

`simple string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.upper Example", overlay=true)
if barstate.islast {
    label.new(bar_index, high, text=str.upper(syminfo.ticker))
}
```

## `str.upper` (function, overload 4)

**Definition**

Converts a string to upper case; the other half of the pair with str.lower.

It takes the string and nothing else.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
str.upper(series string source) → series string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `source` | `series string` | yes | String to be converted. |

**Returns**

`series string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("str.upper Example", overlay=true)
if barstate.islast {
    label.new(bar_index, high, text=str.upper(syminfo.ticker))
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.