E-Mail validation with Java and regular expressions (regex)
With a few lines of code you can check if an E-Mail address ist valid or not. The most import part ist our pattern:
String pattern = "([a-z0-9_.-]+@[a-z0-9-]+\\.[a-z]{2,6})";
import java.util.regex.*;
public class EmailCheck {
public static void main(String[] args) {
String eMail = "youremailyoursite.com";
String pattern = "([a-z0-9_.-]+@[a-z0-9-]+\\.[a-z]{2,6})";
if(eMail.matches(pattern)){
System.out.println("Your E-Mail address is valid");
}else{
System.out.println("You entered a not valid E-Mail address");
}
}
}
Similar entries
- Regex (regular expression) password check with Java
- My Yahoo Email Account Hacked, how can I get it back?
- Yahoo Mail Plus + Pop and Mozilla Thunderbird emptied my Inbox, need restore
- How to override php mail function to catch abuse / spammer
- PHP code examples for beginners
- What is difference between POP, IMAP and Webmail
- We can't provide service under the Gmail name in Germany
- Check password strength / safety with PHP and Regex
- Replace string in big database or large text file
- Hide your email address + mailto link with javascript from spammer
- Drupal does not send Email on Hosteurope
- Web2 style secure & flexible free php contact form with easy setup
- Mysql: update weight by an auto-incremented string created on the fly
- Invalid utf8 character string
- Facebook error
- Black-White theme for Notepad++ (for Programmers)
- What is my IP Address and HostName?
- Date, Time, IP Address and browser type for contact form
- How to hide / encrypt CCK Email field with JS against spammer
- How to select a secure password for your online logins

Comments
Post new comment