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)
if text then
local matches = { string.match(text, pattern) } local matches = { string.match(text, pattern) }
if next(matches) then if next(matches) then
return matches return matches
end end
end
-- nil -- nil
end end