str.match

Returns the first part of source that matches the regular expression pattern. Patterns are written in RE2 syntax, which has no backreferences and no lookaround. A pattern that will not compile is not an error: the call returns empty text.

str.match(const string source, const string pattern) → const string
str.match(input string source, input string pattern) → input string
str.match(series string source, series string pattern) → series string
str.match(simple string source, simple string pattern) → simple string
ParameterTypeRequiredDescription
sourceconst stringyesthe string to match against
patternconst stringyesthe pattern to apply

Returns const string or input string or series string or simple string — The matched text, or empty text where nothing matched or the pattern would not compile.

indicator("First run of digits")
alert(str.match(syminfo.ticker, "[0-9]+"))
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