String
Methods for the string type.
| Name | Summary |
|---|---|
| asciiAt | Returns the ASCII value of the character at the specified index. |
| contains | Returns true if the string contains the specified substring. |
| endsWith | Returns true if the string ends with the specified suffix. |
| format | Formats the string using the specified format string and arguments. |
| indexOf | Returns the index of the first occurrence of the specified substring, or -1 if not found. |
| len | Returns the number of characters in the string. |
| repeat | Returns a new string with the specified string repeated the specified number of times. |
| replace | Returns a new string with all occurrences of 'old' replaced by 'new'. |
| split | Splits the string into a slice of substrings separated by the specified delimiter. |
| startsWith | Returns true if the string starts with the specified prefix. |
| toLower | Returns a new string with all characters converted to lowercase. |
| toUpper | Returns a new string with all characters converted to uppercase. |
| trimSpace | Returns a new string with leading and trailing white space removed. |
Returns the ASCII value of the character at the specified index.
Parameters
| index | The index of the character to get the ASCII value of. |
result<int>
fn string.contains(substring) -> bool
Returns true if the string contains the specified substring.
Parameters
| substring | The substring to search for. |
bool
fn string.endsWith(suffix) -> bool
Returns true if the string ends with the specified suffix.
Parameters
| suffix | The suffix to search for. |
bool
fn string.indexOf(substring) -> int
Returns the index of the first occurrence of the specified substring, or -1 if not found.
Parameters
| substring | The substring to search for. |
int
fn string.len() -> int
Returns the number of characters in the string.
Returns
int
Returns a new string with all occurrences of 'old' replaced by 'new'.
Parameters
| old | The substring to be replaced. |
| new | The substring to replace with. |
Splits the string into a slice of substrings separated by the specified delimiter.
Parameters
| delim | The substring to split by. |
[]string
fn string.startsWith(prefix) -> bool
Returns true if the string starts with the specified prefix.
Parameters
| prefix | The prefix to search for. |
bool