Jump to content

Mail format


Piorun

Recommended Posts

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...