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
- Replace string in big database or large text file
- Check password strength / safety with PHP and Regex
- Drupal does not send Email on Hosteurope
- Hide your email address + mailto link with javascript from spammer
- Web2 style secure & flexible free php contact form with easy setup
- Web2 style sicheres & flexibles free PHP-Formular with easy setup
- Facebook error
- How to select a secure password for your online logins
- What is my IP Address and HostName?
- Mysql replace with regexp
- Unable to send e-mail. Please contact the site admin, if the problem persists (Drupal Error)
- Search only in .php files under linux
- How to hide / encrypt CCK Email field with JS against spammer
- Include both php/ html files, catch & assign output to a string variable
- Howto protect admin.php / login.php with htaccess password












Comments
Post new comment