Create is_uuid.lua
Add a new lua function to determine if a string is a uuid.
This commit is contained in:
@@ -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
|
||||||
Reference in New Issue
Block a user