Make `regex.match` return all the results
This commit is contained in:
parent
74f7389cac
commit
14be51b1ec
|
@ -5,8 +5,9 @@ regex.__index = function(table, key) return regex[key]; end
|
||||||
regex.match = function(pattern_string, string, offset, options)
|
regex.match = function(pattern_string, string, offset, options)
|
||||||
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 s, e = regex.cmatch(pattern, string, offset or 1, options or 0)
|
local res = { regex.cmatch(pattern, string, offset or 1, options or 0) }
|
||||||
return s, e and e - 1
|
res[2] = res[2] and res[2] - 1
|
||||||
|
return table.unpack(res)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Will iterate back through any UTF-8 bytes so that we don't replace bits
|
-- Will iterate back through any UTF-8 bytes so that we don't replace bits
|
||||||
|
|
Loading…
Reference in New Issue