String.split_by_first

split_by_first :: fn (str: string, delimiter: u8, lhs: *string, rhs: *string, di: *s32) bool

Split input string str into two tokens based on the first 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.

Token destination pointers lhs and rhs are optional.

Warning

lhs and rhs sub strings are not guaranteed to be zero terminated and they are not supposed to be freed.

Example

main :: fn () s32 {
    lhs: string;
    rhs: string;
    if String.split_by_first("this/is/my/epic/path", '/', &lhs, &rhs) {
        print("lhs = %\n", lhs);
        print("rhs = %\n", rhs);
    }

    return 0;
}

Declared in: string.bl