From 867f3434f35302dead55845b6a6d4568f18fd04a Mon Sep 17 00:00:00 2001 From: xeals Date: Tue, 15 Jan 2019 15:57:44 +1100 Subject: [PATCH] feat(std): add string splitter --- lib/std.fnl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/std.fnl b/lib/std.fnl index 18650aa..80dcd13 100644 --- a/lib/std.fnl +++ b/lib/std.fnl @@ -20,5 +20,13 @@ (or (= nil s) (= "" s))) +(fn std.s-split [s sep] + (var t {}) + (let [sep (or sep "%s") + re (.. "([^" sep "]+)")] + (each [str (string.gmatch s re)] + (table.insert t str)) + t)) + std ;;; std.fnl ends here