tyczj tyczj - 1 year ago 97
Java Question

getting a section of a string

Let's say I have an email address string such as

"John Smith" <JSmith@gmail.com>
and all I want is to get the email address inside the

How would I do that while not getting everything else?

Answer Source

Since it sounds like you're dealing with standard format email addresses (RFC 822) you might want to consider using the JavaMail API. The code for what you want is simple with it. E.g., assuming input contains your email address string:

String email = new InternetAddress(input).getAddress();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download