Files
lix/lix/libexpr/builtins/substring.md
T
Charles Hall 93a4f0e82d document the behavior of negative substring len
Change-Id: I0777580a3aa374400586b76afdc74da5b5f6645a
2025-02-16 15:18:19 -08:00

558 B

name, args
name args
substring
start
len
s

Return the substring of s from character position start (zero-based) up to but not including start + len. If start is greater than the length of the string, an empty string is returned, and if start + len lies beyond the end of the string or len is negative, only the substring up to the end of the string is returned. start must be non-negative. For example,

builtins.substring 0 3 "nixos"

evaluates to "nix", and

builtins.substring 3 (-1) "nixos"

evaluates to "os".