feat(std): add string splitter

This commit is contained in:
xeals 2019-01-15 15:57:44 +11:00
parent 818b38bef7
commit 867f3434f3

View File

@ -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