query
On this page

splitString

lib.splitString

Docs pulled from | This Revision | 24 minutes ago


Nixpkgs manual

Cut a string with a separator and produces a list of strings which were separated by this separator.

Inputs

sep
1. Function argument
s
2. Function argument

Type

splitString :: String -> String -> [String]

Examples

lib.strings.splitString usage example

splitString "." "foo.bar.baz"
=> [ "foo" "bar" "baz" ]
splitString "/" "/usr/local/bin"
=> [ "" "usr" "local" "bin" ]
(lib.strings.splitString)

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

splitString =
    sep:
    let
      escapedSep = escapeRegex (toString sep);
    in
    s: map (addContextFrom s) (filter isString (split escapedSep (toString s)));