From 62008e7eb7f48baff798fb8cd72164d78a01f924 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Sat, 23 Jul 2022 19:54:49 -0400 Subject: [PATCH] ADD gmatch to table function --- src/pure.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/pure.lua b/src/pure.lua index db4b93c..4efabe5 100644 --- a/src/pure.lua +++ b/src/pure.lua @@ -2,7 +2,9 @@ local M = {} local err = require 'err' +local __string_gmatch = string.gmatch local __math_floor = math.floor +local __table_insert = table.insert -------------------------------------------------------------------------------- -- zippy functions @@ -175,6 +177,14 @@ M.table_array = function(tbl) return r end +M.gmatch_table = function(pat, s) + local r = {} + for m in __string_gmatch(s, pat) do + __table_insert(r, m) + end + return r +end + -------------------------------------------------------------------------------- -- functional functions