I am making an Email Parser program.
The email should follow following rules:
• The prefix or the user-id (i.e. the characters before @) should contain at least 6 and maximum of 15 characters. • The domain name (i.e. the characters after @ and before dot) should contain at least 3 and maximum of 8 characters. • The extension (i.e. the characters after dot) must contain exactly 3 characters. • The extension must be one of the following three types: com, org and edu.

Pattern p = Pattern.compile("[@.]{6,15}@\\w{3,8}\\.(com|org|edu)$");

Is the above code line correct? As on every input the message for invalid email is occuring.. Thanks

I haven't check your pattern but I know following is working :)

^[_A-Za-z0-9-]{6,15}@[A-Za-z0-9]{3,8}(\\.[A-Za-z]{3})$
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.