std::strings
Functions
fn Repeat(s: str, mut n: int): str
Returns string that equals to concatenation of n-count s. Returns empty string is n <= 0.
fn HasPrefix(s: str, sub: str): bool
Reports string has prefix as specified substring or not.
fn HasSuffix(s: str, sub: str): bool
Reports string has suffix as specified substring or not.
fn Find(s: str, sub: str): int
Returns index of first matched item with specified substring, returns -1 if not exist any match. Starts searching at left of string to right.
fn FindLast(s: str, sub: str): int
Returns index of first matched item with specified substring, returns -1 if not exist any match. Starts searching at right of string to left.
fn FindAt(s: str, sub: str, mut i: int): int
Returns index of first matched item with specified substring, returns -1 if not exist any match. Starts searching at left of string to right. Starts searching s at given index. Returns -1, if i < 0 || i >= len(s).
fn FindLastAt(s: str, sub: str, i: int): int
Returns index of first matched item with specified substring, returns -1 if not exist any match. Starts searching at right of string to left. Starts searching s at given index. Returns -1, if i < 0 || i >= len(s).
fn FindFn(s: str, f: fn(mut rune): bool): int
Returns index of first matched item with finder function, returns -1 if not exist any match. Starts searching at left of string to right.
fn FindFnAt(s: str, mut i: int, f: fn(mut rune): bool): int
Returns index of first matched item with finder function, returns -1 if not exist any match. Starts searching at left of string to right. Starts searching s at given index. Returns -1, if i < 0.
fn FindFnLastAt(s: str, mut i: int, f: fn(mut rune): bool): int
Returns index of first matched item with finder function, returns -1 if not exist any match. Starts searching at right of string to left. Starts searching s at given index. Returns -1, if i < 0 || i >= len(s).
fn FindFnLast(s: str, f: fn(mut rune): bool): int
Returns index of first matched item with finder function, returns -1 if not exist any match. Starts searching at right of string to left.
fn FindAny(s: str, runes: str): int
Returns index of first matched item with any of runes, returns -1 if not exist any match. Starts searching at right of string to left.
fn FindLastAny(s: str, runes: str): int
Returns index of first matched item with any of runes, returns -1 if not exist any match. Starts searching at right of string to left.
fn Split(s: str, sub: str, mut n: int): []str
Splits the string into the specified number of parts to the specified substring. Returns empty slice if n is equals to zero. Returns all parts if n less than zero.
fn Contains(s: str, sub: str): bool
Reports whether string includes substring.
fn ContainsByte(s: str, b: byte): bool
Reports whether string includes byte.
fn ContainsRune(s: str, r: rune): bool
Reports whether string includes rune.
fn ContainsAny(s: str, runes: str): bool
Reports whether string includes any of runes.
fn Count(s: str, sub: str): int
Counts the number of non-overlapping instances of substring in s. Returns zero if substring is empty.
fn Replace(s: str, sub: str, new: str, mut n: int): str
Replaces all substrings matching sub in the string with new. Returns same string if n is equals to zero. Replaces all matches if n less than zero.
fn Map(s: str, mapping: fn(mut rune): rune): str
Returns a copy of the string s with all its characters modified according to the mapping function. If mapping returns a negative value, the character is dropped from the string with no replacement.
fn ToLower(s: str): str
Returns s with all Unicode letters mapped to their lower case.
fn ToUpper(s: str): str
Returns s with all Unicode letters mapped to their upper case.
fn FindRune(s: str, r: rune): int
Returns index of first matched item with specified rune, returns -1 if not exist any match. Starts searching at left of string to right.
fn FindLastRune(s: str, r: rune): int
Returns index of first matched item with specified rune, returns -1 if not exist any match. Starts searching at right of string to left.
fn FindByte(s: str, b: byte): int
Returns index of first matched item with specified byte, returns -1 if not exist any match. Starts searching at left of string to right.
fn FindLastByte(s: str, b: byte): int
Returns index of first matched item with specified byte, returns -1 if not exist any match. Starts searching at right of string to left.
fn TrimLeft(s: str, cutset: str): str
Trims string by specified runes at left. Cutset should include runes to trim.
fn TrimRight(s: str, cutset: str): str
Trims string by specified runes at right. Cutset should include runes to trim.
fn Trim(s: str, cutset: str): str
Trims string by specified runes at left and right. Cutset should include runes to trim.
fn Join(parts: []str, sep: str): str
Concatenates the parts of its first argument to create a single string. The separator sep is placed between parts in the resulting string.