Returns true when a string finishes with the text you give.
str.endswith(source, str) compares the closing characters of source with str. Upper and lower case letters are treated as different.
It suits suffix checks such as a currency code at the end of a symbol name.
Syntax
str.endswith(source: const string, str: const string) -> const bool
str.endswith(source: simple string, str: simple string) -> simple bool
str.endswith(source: series string, str: series string) -> series boolArguments
| Name | Type | Default | Description |
|---|---|---|---|
| source | const/ | required | The text whose ending is checked. The test is case sensitive. |
| str | const/ | required | The suffix to compare with the end of source. An empty suffix always matches. |
Returns
const/simple/series bool: true if source ends with str.
Remarks
- An empty suffix always matches.
Example
//@version=6
indicator("Ends with")
plot(str.endswith(syminfo.ticker, "A") ? 1 : 0, "Ends with A", color = color.orange, style = plot.style_stepline)See also
Runs on Sidechair