update string.match

This commit is contained in:
Pinya
2017-12-31 18:33:49 +03:00
parent ada0cb48d1
commit 9ec51f8743
+9 -1
View File
@@ -109,7 +109,15 @@ function string.match(str, pattern, index)
index = index ~= "" and tonumber(index) or nil
end
return gfind(index and sub(str, index) or str, gsub(pattern, "%^", ""))() or ""
local i1, i2, match, match2 = find(str, pattern, index)
if not match and i2 and i2 >= i1 then
return sub(str, i1, i2)
elseif match2 then
return select(3, find(str, pattern, index))
end
return match
end
strmatch = string.match