Originally posted by yes boss:
Pattern p=Pattern.compile("[a-zA-Z]*[0-9]*@[a-zA-Z]*.[a-zA-Z]*");
If i m using email as either 13gaurav@xyz.com or gaurav_123@xyz.com
These two examples simply don't match your pattern. Your pattern says "zero or more letters, followed by zero or more digits, follwed by @, followed by zero or more letters, follwoed by any character (note that the . is a special char in regexp, to match the char '.', it must be escaped '\.'), followed by zero or more letters.
I guess
you should rethink your pattern or dive deeper into regexp to learn how to use them correctly.
Besides the options already mentioned, you could look at the commons-validator package from apache to validate the correct form of an email adress (and many more validations).
Kind regards,
Uli
[ May 21, 2008: Message edited by: Uli Hofstoetter ]