Hello everyone,
I was wondering if there is set of builtin functions to operate on strings in nix.
Like converting string to uppercase or lowercase,use sub-sequences.
Thanks
Yes, thereâs lib.toUpper
and lib.toLower
. Play around with them using nix repl
nix-repl> builtins.substring 0 4 "hello, world"
"hell"
nix-repl> lib.toUpper "hello, world"
"HELLO, WORLD"
nix-repl> lib.toLower "HELLO, WORLD"
"hello, world"
Thx for the reply but here is the full output after running that in nix-repl
nix-repl> lib.toUpper ânix replâ
error: undefined variable âlibâ
at «string»:1:1:
1| lib.toUpper "nix repl"
| ^
nix-repl>
you need to import lib. if youâre using flakes nix repl nixpkgs
will add it. Otherwise :l <nixpkgs>
Apologies, I should have made that clear
1 Like