We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

String manipulation

tricks801
tricks801 asked
on
Medium Priority
433 Views
Last Modified: 2013-11-24
What is a good way to test if a user entered value is in a valid email format? i.e. myName@myDomain.com
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2016

Commented:
Try

final String MAIL_RE = "^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$";

boolean validEmail = input.matches(MAIL_RE);
CERTIFIED EXPERT
Top Expert 2016
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
i received an illegal escape character at some . and -
CERTIFIED EXPERT
Top Expert 2016

Commented:
Did you miss my correction?
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Top Expert 2016

Commented:
>>this'll do a bit better

Why so - in what way?
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Top Expert 2004
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Top Expert 2016

Commented:
>>If you already have javamail package

AFAIK the package only makes relatively crude checks on address validity
CERTIFIED EXPERT
Top Expert 2016

Commented:
8-)
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
Top Expert 2004

Commented:
:-)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.