Fix problem in regex.gsub
The local n was not initialized and the "string" argument was shadowing the Lua's "string" module.
This commit is contained in:
parent
a100a7b6a9
commit
ba48cb1382
|
@ -35,10 +35,11 @@ end
|
||||||
-- transformations and stuff in lua. Currently, this takes group replacements
|
-- transformations and stuff in lua. Currently, this takes group replacements
|
||||||
-- as \1 - \9.
|
-- as \1 - \9.
|
||||||
-- Should work on UTF-8 text.
|
-- Should work on UTF-8 text.
|
||||||
regex.gsub = function(pattern_string, string, replacement)
|
regex.gsub = function(pattern_string, str, replacement)
|
||||||
local pattern = type(pattern_string) == "table" and
|
local pattern = type(pattern_string) == "table" and
|
||||||
pattern_string or regex.compile(pattern_string)
|
pattern_string or regex.compile(pattern_string)
|
||||||
local result, str, indices, n = "", string
|
local result, indices = ""
|
||||||
|
local n = 0
|
||||||
repeat
|
repeat
|
||||||
indices = { regex.cmatch(pattern, str) }
|
indices = { regex.cmatch(pattern, str) }
|
||||||
if #indices > 0 then
|
if #indices > 0 then
|
||||||
|
|
Loading…
Reference in New Issue