ngx.re.match with "jo" option is significantly faster than string.match but ngx.re.match without "jo" option seem to be slower.
e.g in below test, ngx.re.match with "jo" takes 3 second vs 10 seconds for string.match on my laptop.
local ngx_re_match = ngx.re.match
local string_match = string.match
local s=[[\n5463463463565fhfghfghfgdhfhgfhhdfg\n<key>abcd</key>fdfdsdsfgdfhhfghgfdhgfhfgh<msgid>1234</msgid>4656456645366456464363466dfdfd <v1:Cmd Name=\"1\">dsfdsfsdfsfsf</v1:Cmd>]]
local regex = "<key>(.*)</key>.*<msgid>(.*)</msgid>.*<v1:Cmd.*>(.*)</v1:Cmd>"
local regex_jo = "jo"
local count = 500000
local t1= os.time()
for i = 1, count do
--print(ngx_re_match(s,"<key>(.*)</key>.*<msgid>(.*)</msgid>.*<v1:Cmd.*>(.*)</v1:Cmd>","jo"))
local a =ngx_re_match(s,regex, regex_jo)
end
print(os.time()-t1)
local t1= os.time()
for i = 1, count do
--print(string.match(s,regex))
local a = string_match(s,regex, 1, regex_jo)
end
print(os.time()-t1)