Hey

How do I correctly validate that a email is in the correct format?

I tried using the Apache Commons Validator library but, since Im using a web service, it seems not to want to fix it up and use it. I comply the code, make the aar, put it on the server, and it pops up a error saying it cant find the class when it works when coding and is included in the build path.

So what other ways can I correctly validate that a email is in the correct format?

Thanks!

you can easily write a method that does that, or a simple regex validation would suffice. off course, this would only check whether or not the e-mail address is 'formed' as an email-addres: <userName>@<hostname>.<domain>, it wouldn't check whether or not the e-mail address entered actually exists or not.

you can easily write a method that does that, or a simple regex validation would suffice. off course, this would only check whether or not the e-mail address is 'formed' as an email-addres: <userName>@<hostname>.<domain>, it wouldn't check whether or not the e-mail address entered actually exists or not.

Well, if it doesnt exist, that really doesnt matter to me as my email will always exist.

How can I validate it using a regular expression (regex)?

as I said: countless examples out there exist. it also depends on how you want your validation to go.
they are just ment as exactly what they are: examples, you'll have to modify them to get something you want to be 100% correct.

it also depends on how you want your validation to go.

Im not really sure what you ment by that.

Valid emails:
hi@aol.com
more.names@hello.aol.com

Things like that

Invalid
hiataol.com

hi@aol.com@

This article has been dead for over six months. Start a new discussion instead.