string_split_by_last
Declaration
string_split_by_last :: fn (str: string, delimiter: u8, lhs: *string, rhs: *string) bool
Description
Split input string str
into two tokens based on the last occurrence of delimiter
.
Delimiter is not included in resulting tokens. Result tokens only points into original
memory of the str
, they are not supposed to be freed.
When delimiter is not present in the input string function return false
, lhs
and
rhs
buffers are not modified, otherwise function return true
and sets lhs
and rhs
to found values.
Arguments
str
String to be splitted.delimiter
Delimiter to be found.lhs
Optional output left hand side string.rhs
Optional output right hand side string.
Result
True when delimiter was found.
Example
main :: fn () s32 {
lhs: string;
rhs: string;
if string_split_by_last("this/is/my/epic/path", '/', &lhs, &rhs) {
print("lhs = %\n", lhs);
print("rhs = %\n", rhs);
}
return 0;
}
Declared in: string.bl