Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4274712
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:53:03+00:00 2026-05-21T07:53:03+00:00

I am trying to find a simple method to check to see if a

  • 0

I am trying to find a simple method to check to see if a user’s input meets a couple criteria for an email address. I’ve read through many threads on this subject and most seem to want to validate the email address too. I’m not trying to build some super duper email address validator/checker. I’m trying to build a method that checks for these things:

  1. The string entered by the user contains the ‘@’ sign.
  2. There are at least two characters before the ‘@’ sign.
  3. There is a ‘.’ after the at sign followed by only three characters. The domain name can be as long as needed, but the string must end with “._ _ _”. As in “.com” or “.net”…

I understand that this is not an all encompassing email address checker. That’s not what I want though. I want just something this simple. I know that this is probably a routine question but I can’t figure it out even after reading all of the seriously crazy ways of validating an email address.

This is the code I have so far: (Don’t worry I already know it’s pretty pathetic…. )

public static void checkEmail()
{
    validEmail(emailAddresses);
    if(validEmail(emailAddresses))
    {

    }
}

public static boolean validEmail(String email) {
    return email.matches("[A-Z0-9._%+-][A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{3}");
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T07:53:04+00:00Added an answer on May 21, 2026 at 7:53 am

    Not perfect, but gets the job done.

    static boolean validEmail(String email) {
        // editing to make requirements listed
        // return email.matches("[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}");
        return email.matches("[A-Z0-9._%+-][A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{3}");
    }
    
    void checkEmails() {
        for(String email : emailAddresses) {
            if(validEmail(email)) {
                 // it's a good email - do something good with it
            }
            else {
                 // it's a bad email - do something... bad to it? sounds dirty...
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to find a good and simple method to signal child processes (created
I'm trying to find a simple method of getting all the links spread evenly
I am trying to find simple, elegant way to get all the pertinent name,value
I'm trying to find a simple solution to a specific problem, which is a
I'm trying to find a simple way to call a NSLog to trace myPoint
I am trying to find a simple yet powerful way to distribute the video
I am trying to find the best option to create a simple progress bar
I am writing a simple program, which is trying to find next palindrome number
it's a simple issue about optim() function on R. I am trying to find
I'm trying to make a simple php script to find all src attributes from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.