Sunday, May 30, 2010

java regex to validate email

/**
*@author Sunny Jain
*@Email i_look_like_sunny@hotmail.com
*@version 1.0
*@since 02-March-2010
*@about - this Class will use regular express to validate the email address.
*\\p{Alpha} means - any alphabet ( case insensitive)
*\\p{Alnum} means - any alphabet + any digit ( case insensitive)
*It checks any email address that ends with .com, .org, and co.(any country)
*/

public class Main {

public static void main(String... args){
String alpha = "i_look_like_sunny@hotmail.co.in";
String ALPHAREGEX = "[\\p{Alpha}]+[\\p{Alnum}_.]*[@][\\p{Alnum}]+[.]" +
"(([cC][oO][mM])|([oO][rR][gG])|([cC][oO][.][\\p{Alpha}]*))";

System.out.println(ALPHAREGEX);
System.out.println(alpha.matches(ALPHAREGEX));
}
}

5 comments:

Md.Fazlul Bari said...

Welcome to our website
java training that is the largest professional java training site where java,
java training, online java course, java training in Virginia,
java programming are available

more detail.......
online java course
java programming
java training in Virginia

ganesh said...


Hi there, awesome site. I thought the topics you posted on were very interesting. I tried to add your RSS to my feed reader and it a few. take a look at it,

hopefully I can add you and follow.


Java Training Courses

Azizul@top10websitehosting said...


Sexy Lingerie Adult Clothing Superstore Sex Shop Womens Lingerie
Welcome to SexyEveningDelights.com, we carry a large selection of lingerie, adult toys and adult novelties,the best

adult items. Spice up your sex life, a sexy thong, a sexy bra, some sexy lingerie or some sexy panties. Maybe some Adult Toys to enhance your relationship. Or even a

wig or costume for some dress up fun, we've carry a wide assortment of items to fullfill your ultimate sexual

fantasies
.

Eric Simmons said...

Great and Useful Article.

Online Java Training

Online Java Training from India

Java Online Training

Online Java Training India

Java Training Institutes in Chennai

Java Course in Chennai

Java Training in Chennai

Java Interview Questions

Java Tutorials

Core Java Interview Questions

Eric Simmons said...

Great and Useful Article.

Online Java Training

Online Java Training from India

Java Online Training

Online Java Training India

Java Training Institutes in Chennai

Java Course in Chennai

Java Training in Chennai

Java Interview Questions

Java Tutorials

Core Java Interview Questions