Lipi Reference
Lipi

Functions

str.substring()

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. This edition does not state what they are counted from, or whether the end position is included in the result.

Syntax · 1 of 8

                str.substring(const string source, const int start, const int end) → const string
              

Arguments

source required const string The ending position. It is exclusive (the extracted string does NOT include that position's character). Optional. The default is the length of the source string.
start required const int The beginning position of the extracted substring. It is inclusive (the extracted substring includes the character at that position).
end required const int Source string from which to extract the substring.

Return Type

const string

Syntax · 2 of 8

                str.substring(input string source, input int start, input int end) → input string
              

Arguments

source required input string The ending position. It is exclusive (the extracted string does NOT include that position's character). Optional. The default is the length of the source string.
start required input int The beginning position of the extracted substring. It is inclusive (the extracted substring includes the character at that position).
end required input int Source string from which to extract the substring.

Return Type

input string

Syntax · 3 of 8

                str.substring(simple string source, simple int start, simple int end) → simple string
              

Arguments

source required simple string The ending position. It is exclusive (the extracted string does NOT include that position's character). Optional. The default is the length of the source string.
start required simple int The beginning position of the extracted substring. It is inclusive (the extracted substring includes the character at that position).
end required simple int Source string from which to extract the substring.

Return Type

simple string

Syntax · 4 of 8

                str.substring(series string source, series int start, series int end) → series string
              

Arguments

source required series string The ending position. It is exclusive (the extracted string does NOT include that position's character). Optional. The default is the length of the source string.
start required series int The beginning position of the extracted substring. It is inclusive (the extracted substring includes the character at that position).
end required series int Source string from which to extract the substring.

Return Type

series string

Syntax · 5 of 8

                str.substring(const string source, const int start) → const string
              

Arguments

source required const string The ending position. It is exclusive (the extracted string does NOT include that position's character). Optional. The default is the length of the source string.
start required const int The beginning position of the extracted substring. It is inclusive (the extracted substring includes the character at that position).

Return Type

const string

Syntax · 6 of 8

                str.substring(input string source, input int start) → input string
              

Arguments

source required input string The ending position. It is exclusive (the extracted string does NOT include that position's character). Optional. The default is the length of the source string.
start required input int The beginning position of the extracted substring. It is inclusive (the extracted substring includes the character at that position).

Return Type

input string

Syntax · 7 of 8

                str.substring(simple string source, simple int start) → simple string
              

Arguments

source required simple string The ending position. It is exclusive (the extracted string does NOT include that position's character). Optional. The default is the length of the source string.
start required simple int The beginning position of the extracted substring. It is inclusive (the extracted substring includes the character at that position).

Return Type

simple string

Syntax · 8 of 8

                str.substring(series string source, series int start) → series string
              

Arguments

source required series string The ending position. It is exclusive (the extracted string does NOT include that position's character). Optional. The default is the length of the source string.
start required series int The beginning position of the extracted substring. It is inclusive (the extracted substring includes the character at that position).

Return Type

series string

Example


          //@lipi=2
indicator("String Substring Example", overlay=false)
myStr = "GoCharting is powerful"
subStr = str.substring(myStr, 0, 10)
plot(close, title=subStr)