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 stringstr.match(input string source, input string pattern) → input stringstr.match(series string source, series string pattern) → series stringstr.match(simple string source, simple string pattern) → simple string| Parameter | Type | Required | Description |
|---|---|---|---|
source | const string | yes | the string to match against |
pattern | const string | yes | the 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.