str.substring() - Pine Script Function
str.substring()
Section titled “str.substring()”Overview
Section titled “Overview”Returns a new string that is a substring of the source string. The substring begins with the character at the index specified by begin_pos and extends to ‘end_pos - 1’ of the source string.
Syntax
Section titled “Syntax”str.substring(source, begin_pos, end_pos) → const stringParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| source | const string | Source string from which to extract the substring. |
Returns
Section titled “Returns”The substring extracted from the source string.
Remarks
Section titled “Remarks”- Strings indexing starts from 0. If begin_pos is equal to end_pos, the function returns an empty string.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("str.substring", overlay = true)sym= input.symbol("NASDAQ:AAPL")pos = str.pos(sym, ":") // Get position of ":" charactertkr= str.substring(sym, pos+1) // "AAPL"if barstate.islastconfirmedhistorylabel.new(bar_index, high, text = tkr)