lix/src
Eelco Dolstra 976df480c9 Add a primop for regular expression pattern matching
The function ‘builtins.match’ takes a POSIX extended regular
expression and an arbitrary string. It returns ‘null’ if the string
does not match the regular expression. Otherwise, it returns a list
containing substring matches corresponding to parenthesis groups in
the regex. The regex must match the entire string (i.e. there is an
implied "^<pat>$" around the regex).  For example:

  match "foo" "foobar" => null
  match "foo" "foo" => []
  match "f(o+)(.*)" "foooobar" => ["oooo" "bar"]
  match "(.*/)?([^/]*)" "/dir/file.nix" => ["/dir/" "file.nix"]
  match "(.*/)?([^/]*)" "file.nix" => [null "file.nix"]

The following example finds all regular files with extension .nix or
.patch underneath the current directory:

  let

    findFiles = pat: dir: concatLists (mapAttrsToList (name: type:
      if type == "directory" then
        findFiles pat (dir + "/" + name)
      else if type == "regular" && match pat name != null then
        [(dir + "/" + name)]
      else []) (readDir dir));

  in findFiles ".*\\.(nix|patch)" (toString ./.)
2014-11-25 11:47:06 +01:00
..
boost boost::shared_ptr -> std::shared_ptr 2014-03-30 00:49:23 +01:00
bsdiff-4.3 Fix "make dist" 2014-02-01 14:38:12 +01:00
download-via-ssh Settings: Add bool get() 2014-09-17 15:18:13 +02:00
libexpr Add a primop for regular expression pattern matching 2014-11-25 11:47:06 +01:00
libmain Shut up a clang warning 2014-10-31 08:49:15 +01:00
libstore Build derivations in a more predictable order 2014-11-24 16:50:46 +01:00
libutil Add a primop for regular expression pattern matching 2014-11-25 11:47:06 +01:00
nix-daemon nix-daemon: Call exit(), not _exit() 2014-11-19 17:09:27 +01:00
nix-env Add --force-name support for --set in nix-env, to support nix-install-package --set 2014-09-23 15:11:24 +02:00
nix-hash Use proper quotes everywhere 2014-08-20 18:03:48 +02:00
nix-instantiate Rename strictForceValue -> forceValueDeep 2014-09-22 16:05:00 +02:00
nix-log2xml nix-log2xml: Handle newlines 2014-08-13 19:06:20 +02:00
nix-store nix-store -q: Check for conflicting flags 2014-10-14 12:15:39 +02:00