From 9ec51f8743684d68b629abc8a20342ff0428ebb6 Mon Sep 17 00:00:00 2001 From: Pinya <800pin.ru@gmail.com> Date: Sun, 31 Dec 2017 18:33:49 +0300 Subject: [PATCH] update string.match --- !Compatibility/api/luaAPI.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/!Compatibility/api/luaAPI.lua b/!Compatibility/api/luaAPI.lua index f2d4dc6..96c5134 100644 --- a/!Compatibility/api/luaAPI.lua +++ b/!Compatibility/api/luaAPI.lua @@ -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