I have been trying to extract the names and email addresses from the following String that consists of multiple lines through regex in Java:
From: Kane Smith <[email protected]> To: John Smith <[email protected]>, Janes Smith <[email protected]>, Tom Barter <[email protected]>, Other Weird @#$@<>#^Names <[email protected]>, Long Long Long Long Name <[email protected]> Date: Tue, 25 Oct 2011 15:45:59 +0000 I tried this regex: To:\s?(([.*]+)\s*<([\w\d@\.]*)>,(\s|\n)*)+ But it doesn't work.
My intention is to extract each of the names and email addresses and put each name its email address together into groups. What I have done however, seems to work only when there is one single name and address. What should my regex be to do this?