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.

str.substring(const string source, const int start) → const string
str.substring(const string source, const int start, const int end) → const string
str.substring(input string source, input int start) → input string
str.substring(input string source, input int start, input int end) → input string
str.substring(series string source, series int start) → series string
str.substring(series string source, series int start, series int end) → series string
str.substring(simple string source, simple int start) → simple string
str.substring(simple string source, simple int start, simple int end) → simple string
ParameterTypeRequiredDescription
sourceconst stringyesthe string to cut from
startconst intyesthe position the returned piece starts at
endconst intyesthe position the returned piece runs to, in the three-argument form

Returns const string or input string or series string or simple string — The selected text. Positions are counted from zero, and they count characters.

indicator("A piece of a string")
alert(str.substring("breakout", 1))
plot(close)

See also str.contains · str.endswith · str.format_time

Part of the function index.

Ready to put this into practice?
Try GoCharting Premium
Unlock advanced orderflow, market profile, options desk, and real-time data — everything you just read about, live in your charts.
Upgrade