match_pattern checks if text exists

This commit is contained in:
yago 2015-04-12 23:26:01 +02:00
parent 4e4dc7ed11
commit ca97baa60d

View File

@ -441,9 +441,11 @@ end
-- Returns a table with matches or nil -- Returns a table with matches or nil
function match_pattern(pattern, text) function match_pattern(pattern, text)
local matches = { string.match(text, pattern) } if text then
if next(matches) then local matches = { string.match(text, pattern) }
return matches if next(matches) then
return matches
end
end end
-- nil -- nil
end end