I am trying to take a list of eMail addresses along with first and last names and convert them to a CSV format. My eMail addresses are in the following format:
First, Last <email1@example.com>; First, Last <email2@example.com>;
The output I need is the following:
email1@example.com,email2@example.com
I am using the following code:
string[] addresses = addresses_Delimited.Split(new Char[] { '<', '>' });
addresses_Delimited is my list of addresses in the original format.
The problem is that it is not eliminating first and last names; instead it is returning first and last names as entries in the array addresses. So, addresses[0] = "First, Last", addresses[1] = "email1@example.com", and addresses[2] = "; First, Last". All first and last name entries after the first one have a semicolon in them.
How do I make string.Split remove all text outside "<" and ">"? Do I need to use something else?