Piorun Posted December 14, 2013 Share Posted December 14, 2013 Hi Today i decide to write function which will check if string is in good format (e-mail) so here is my string.match function: string.match(mailString, '(%w+)@(%w+).(%w+)') Where 'mailString' is string which will be ckecked. Problem is that this works when we put something like: 'piorun@gmail' and '[email protected]'. I need to check domain too so please help . Thanks a lot. Link to comment
LonelyRoad Posted December 14, 2013 Share Posted December 14, 2013 function validateEmail(email) local email = tostring(email) if (email:match("[A-Za-z0-9%.%%%+%-]+@[A-Za-z0-9%.%%%+%-]+%.%w%w%w?%w?")) then return true else return false end end This parses emails a lot better from my experience, and should resolve your issue. Link to comment
Piorun Posted December 14, 2013 Author Share Posted December 14, 2013 Sweet, thanks. Your function have a bit problem cause if i write "[email protected]....." it returns true but its just little bug to fix Anyway thanks Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now