From ba48cb1382b4b1bd60ec555cce13fe503903e241 Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Fri, 7 May 2021 10:44:38 +0200 Subject: [PATCH] Fix problem in regex.gsub The local n was not initialized and the "string" argument was shadowing the Lua's "string" module. --- data/core/regex.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/data/core/regex.lua b/data/core/regex.lua index 690e04b0..a6ee0d5a 100644 --- a/data/core/regex.lua +++ b/data/core/regex.lua @@ -35,10 +35,11 @@ end -- transformations and stuff in lua. Currently, this takes group replacements -- as \1 - \9. -- Should work on UTF-8 text. -regex.gsub = function(pattern_string, string, replacement) - local pattern = type(pattern_string) == "table" and +regex.gsub = function(pattern_string, str, replacement) + local pattern = type(pattern_string) == "table" and pattern_string or regex.compile(pattern_string) - local result, str, indices, n = "", string + local result, indices = "" + local n = 0 repeat indices = { regex.cmatch(pattern, str) } if #indices > 0 then