Nix Language Quirks: Difference between revisions
Link to manual for indented strings. Also change capitalization to match manual Tags: Mobile edit Mobile web edit |
→builtins.replaceStrings key match on "": Improve grammar and formatting Tags: Mobile edit Mobile web edit |
||
| Line 113: | Line 113: | ||
</syntaxHighlight> | </syntaxHighlight> | ||
The [https://noogle.dev/f/builtins/replaceStrings <code>builtins.replaceStrings</code>] function allows matching <code>""</code> in <code>string</code>. <code>[match]</code> gets checked sequentially, and when <code>""</code> is checked - it ''always'' matches. And so - when <code>""</code> is checked it ''always'' inserts the corresponding replacement from <code>[replace]</code>, then the next char in <code>string</code> gets inserted, and then the next char after that from <code>string</code> gets processed. | |||
<syntaxHighlight lang=nix> | <syntaxHighlight lang=nix> | ||
nix-repl> builtins.replaceStrings ["" "e"] [" " "i"] "Hello world" | nix-repl> builtins.replaceStrings ["" "e"] [" " "i"] "Hello world" | ||