Question: I have a string `"Test Test <test@test.com>"` I need to split the email address only if the String is present in this format or else no need to spilt.
I have not got any solutions for this to show my approach.

I need to split email address only if present in the above mentioned format.

Answer: 
You can extract email like this.

```
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class HelloWorld {

    public static void main( String[] args ) {
        String mydata ="Test Test <test@test.com>";
        Pattern pattern = Pattern.compile(".*<(.*)>");
        Matcher matcher = pattern.matcher(mydata);

        String email = null;
        if (matcher.find())
        {
            email = matcher.group(1);

        }
         System.out.println(email);
    }
}

```
Try this:

```
    String address ="Test Test <test@test.com>";
    String emailAddress = address.replaceFirst(".*<(.*)>", "$1");
    System.out.println(emailAddress);

```