about summary refs log tree commit diff
path: root/tvix/eval/src/tests/tvix_tests/eval-okay-regex-match.nix
blob: f774e00a215a04f7d43962b1333b40bc3b4974df (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
with builtins;

let

  matches = pat: s: match pat s != null;

  splitFN = match "((.*)/)?([^/]*)\\.(nix|cc)";

in

[
  (matches "foobar" "foobar")
  (matches "fo*" "f")
  (matches "fo+" "f")
  (matches "fo*" "fo")
  (matches "fo*" "foo")
  (matches "fo+" "foo")
  (matches "fo{1,2}" "foo")
  (matches "fo{1,2}" "fooo")
  (matches "fo*" "foobar")
  (matches "[[:space:]]+([^[:space:]]+)[[:space:]]+" "  foo   ")
  (matches "[[:space:]]+([[:upper:]]+)[[:space:]]+" "  foo   ")

  (match "(.*)\\.nix" "foobar.nix")
  (match "[[:space:]]+([[:upper:]]+)[[:space:]]+" "  FOO   ")

  (splitFN "/path/to/foobar.nix")
  (splitFN "foobar.cc")
]