Create is_uuid.lua

Add a new lua function to determine if a string is a uuid.
This commit is contained in:
FusionPBX
2016-07-23 13:40:57 -06:00
committed by GitHub
parent 35c94dbb4a
commit 2c0452d591

View File

@@ -0,0 +1,13 @@
function is_uuid(s)
if (string.len(s) == 36) then
local x = "%x";
local t = { x:rep(8), x:rep(4), x:rep(4), x:rep(4), x:rep(12) }
local pattern = table.concat(t, '%-');
result = s:match(pattern);
end
if (result == nil) then
return false;
else
return true;
end
end