tyczj tyczj - 1 month ago 16
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

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();