str.replace
Substitutes one piece of text for another inside a string. The source, the old text and the new text are required; the count is optional.
str.replace(const string source, const string old, const string new, const int count) → const stringstr.replace(input string source, input string old, input string new, input int count) → input stringstr.replace(series string source, series string old, series string new, series int count) → series stringstr.replace(simple string source, simple string old, simple string new, simple int count) → simple string| Parameter | Type | Required | Description |
|---|---|---|---|
source | const string | yes | the string to work on |
old | const string | yes | the text to replace |
new | const string | yes | the text to put in its place |
count | const int | no | optional; how many occurrences to replace |
Returns const string or input string or series string or simple string — A string in the form of the arguments you pass.
indicator("One replacement")
alert(str.replace("a-b-c", "-", ":"))
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.