Splits s at the last byte. Returns whether it was found, the part before it and the part after it.
split_from_right :: (
s: string,
byte: u8
) -> (found: bool, left: string, right: string)
When the byte is not found the result is false, all of s and an empty string, as for
split_from_left and the string overload. Both parts point into s.
Parameters
- s: string
- byte: u8
Returns
- found: bool
- left: string
- right: string
found, left, right := split_from_right("a.b.c", #char ".");
assert(found && left == "a.b" && right == "c");
found, left, right = split_from_right("abc", #char ".");
assert(!found && left == "abc" && right == "");split_from_right :: (
s: string,
separator: string
) -> (found: bool, left: string, right: string)
Splits s at the last separator. Returns whether it was found, the part before it and the part after it.
When the separator is not found, or is empty, the result is false, all of s and an empty string.
Parameters
- s: string
- separator: string
Returns
- found: bool
- left: string
- right: string
found, left, right := split_from_right("a::b::c", "::");
assert(found && left == "a::b" && right == "c");