str.replace() - Pine Script Function
str.replace()
Section titled “str.replace()”Overview
Section titled “Overview”Returns a new string with the Nth occurrence of the target string replaced by the replacement string, where N is specified in occurrence.
Syntax
Section titled “Syntax”str.replace(source, target, replacement, occurrence) → const stringParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| source | const string | Source string. |
Returns
Section titled “Returns”Processed string.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("str.replace")var source = "FTX:BTCUSD / FTX:BTCEUR"// Replace first occurrence of "FTX" with "BINANCE" replacement stringvar newSource = str.replace(source, "FTX", "BINANCE", 0)if barstate.islastconfirmedhistory // Display "BINANCE:BTCUSD / FTX:BTCEUR"label.new(bar_index, high, text = newSource)