Results 1 to 6 of 6

Thread: hi guys!!

  1. #1
    durga is offline Member
    Join Date
    Nov 2008
    Posts
    1
    Rep Power
    0

    Default hi guys!!

    can anybody tell me how to validate a set of email id 's using java..

  2. #2
    pjmorce is offline Member
    Join Date
    Nov 2008
    Posts
    17
    Rep Power
    0

    Default

    You can use the Regular expressions facilities...

    import java.util.regex.*;

    class regexSample
    {
    public static void main(String args[])
    {
    //Input the string for validation
    String email = "xyz@hotmail.com";

    //Set the email pattern string
    Pattern p = Pattern.compile(".+@.+\\.[a-z]+");

    //Match the given string with the pattern
    Matcher m = p.matcher(email);

    //check whether match is found
    boolean matchFound = m.matches();

    if (matchFound)
    System.out.println("Valid Email Id.");
    else
    System.out.println("Invalid Email Id.");
    }
    }


  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    pjmorce, it's better give a guide first, before posting a code segment. Reason is our thread poster can confused as well as he/she doesn't learn new things and like to wait until someone post a code segment for there question in future. :)

  4. #4
    pjmorce is offline Member
    Join Date
    Nov 2008
    Posts
    17
    Rep Power
    0

    Default

    You are right.

    Here goes a little tutorial explaining the goal of regular expressions and how they can be used with Java...
    www regular-expressions.info/java.html

    regards

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  6. #6
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    The regex posted up thread is at best a decent first pass. The actual format is a lot more complex. Some of the complexity is probably no longer needed, but the official spec is RFC822

    RFC 822 (rfc822) - STANDARD FOR THE FORMAT OF ARPA INTERNET TEXT MESSAGES

Similar Threads

  1. Hi Guys
    By sneha86 in forum Java Software
    Replies: 8
    Last Post: 01-21-2009, 03:54 PM
  2. Hello Guys.
    By manu_016 in forum Introductions
    Replies: 0
    Last Post: 10-25-2008, 01:01 AM
  3. hi guys!
    By rexson98 in forum Introductions
    Replies: 0
    Last Post: 10-07-2008, 07:07 PM
  4. Hello Guys
    By angelijie in forum Introductions
    Replies: 9
    Last Post: 05-23-2008, 01:18 PM
  5. Help Me Out Guys
    By prince24 in forum New To Java
    Replies: 10
    Last Post: 07-13-2007, 05:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •