Returns true when a string begins with the text you give.
str.startswith(source, str) compares the opening characters of source with str. The comparison is case-sensitive.
Every string starts with an empty string. It is a quick way to group symbols by prefix.
Syntax
str.startswith(source: const string, str: const string) -> const bool
str.startswith(source: simple string, str: simple string) -> simple bool
str.startswith(source: series string, str: series string) -> series boolArguments
| Name | Type | Default | Description |
|---|---|---|---|
| source | const/ | required | The text whose beginning is checked. The test is case sensitive. |
| str | const/ | required | The prefix to compare with the start of source. An empty prefix always matches. |
Returns
const/simple/series bool: true if source begins with str.
Remarks
- Use
str.containswhen the text can sit anywhere, andstr.endswithfor the tail.
Example
//@version=6
indicator("Starts with")
plot(str.startswith(syminfo.ticker, "NV") ? 1 : 0, "Starts with NV", color = color.green, style = plot.style_stepline)See also
Runs on Sidechair