邮箱:
function isRightEmail(str)
if string.len(str or "") < 6 then return false end
local b,e = string.find(str or "", '@')
local bstr = ""
local estr = ""
if b then
bstr = string.sub(str, 1, b-1)
estr = string.sub(str, e+1, -1)
else
return false
end
-- check the string before '@'
local p1,p2 = string.find(bstr, "[%w_]+")
if (p1 ~= 1) or (p2 ~= string.len(bstr)) then return false end
-- check the string after '@'
if string.find(estr, "^[%.]+") then return false end
if string.find(estr, "%.[%.]+") then return false end
if string.find(estr, "@") then return false end
if string.find(estr, "%s") then return false end --空白符
if string.find(estr, "[%.]+$") then return false end
_,count = string.gsub(estr, "%.", "")
if (count < 1 ) or (count > 3) then
return false
end
return true
end
手机:
--第1个[]为手机号第1位,第2个[]为手机号第2位
function checkPhoneNum(str)
return string.match(str,"[1][3,4,5,6,7,8,9]%d%d%d%d%d%d%d%d%d") == str
end