mirror of
https://github.com/divnix/digga.git
synced 2024-11-30 11:02:29 +03:00
be924bcb27
for clarity's sake, expose which function uses final and prev, so that people can have a clearer understanding how they relate to each other in terms of dependencies. also a simple `{ lib = final; }` probably does not warrant a complete callLibs obscurization.
21 lines
518 B
Nix
21 lines
518 B
Nix
{ lib }:
|
|
{
|
|
# returns matching part of _regex_ _string_; null indicates failure.
|
|
rgxToString = regex: string:
|
|
let
|
|
match =
|
|
let
|
|
head = lib.substring 0 1 regex;
|
|
sec = lib.substring 1 2 regex;
|
|
in
|
|
if head == "^"
|
|
|| head == "."
|
|
|| (sec == "*" || sec == "+" || sec == "?")
|
|
then builtins.match "(${regex}).*" string
|
|
else builtins.match ".*(${regex}).*" string;
|
|
in
|
|
if lib.isList match
|
|
then lib.head match
|
|
else null;
|
|
}
|