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 stringstr.substring(const string source, const int start, const int end) → const stringstr.substring(input string source, input int start) → input stringstr.substring(input string source, input int start, input int end) → input stringstr.substring(series string source, series int start) → series stringstr.substring(series string source, series int start, series int end) → series stringstr.substring(simple string source, simple int start) → simple stringstr.substring(simple string source, simple int start, simple int end) → simple string| Parameter | Type | Required | Description |
|---|---|---|---|
source | const string | yes | the string to cut from |
start | const int | yes | the position the returned piece starts at |
end | const int | yes | the 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.