How would I make a basic Java E-mail validation please?
I have a basic Java program (in BlueJ) which accepts an E-mail address field from the user - in the constructor how would I make a basic E-mail validation just to ensure it has the correct @ and '.' within the address please?
I have done a little bit of research on the Internet and found people recommend using regular expressions but I do not really understand.
Any help would be very much appreciated - thank you in advance :-)
You could use regular expressions for that. They are part of the String.matches(String regex) method. This method is called on the email addres, the regex will have to be one which checks for the right syntax. You can find out more about these regular expressions through the following link:
There's even an example of email validation there.
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL