I have this string of proxy addresses, they are separated by an space, however x400 and x500 handles spaces into their addresses. What’s the best approach to split it.
e.g.
smtp:john@a-mygot.com smtp:john@b-mygot.com smtp:john@c-mygot.com X400:C=us;A= ;P=mygot;O=Exchange;S=John;G=Gleen; SMTP:john@mygot.com
Expected result:
smtp:john@a-mygot.com
smtp:john@b-mygot.com
smtp:john@c-mygot.com
X400:C=us;A= ;P=mygot;O=Exchange;S=John;G=Gleen;
SMTP:john@mygot.com
thanks,
EDIT,
string mylist = "smtp:john@a-mygot.com smtp:john@b-mygot.com smtp:john@c-mygot.com X400:C=us;A= ;P=mygot;O=Exchange;S=John;G=Gleen; SMTP:john@mygot.com X500:/o=Example/ou=USA/cn=Recipients of /cn=juser smtp:myaddress";
string[] results = Regex.Split(mylist, @" +(?=\w+:)");
foreach (string part in results)
{
Console.WriteLine(part);
}
Result
smtp:john@a-mygot.com
smtp:john@b-mygot.com
smtp:john@c-mygot.com
X400:C=us;A= ;P=mygot;O=Exchange;S=John;G=Gleen;
SMTP:john@mygot.com
X500:/o=Example/ou=USA/cn=Recipients of /cn=juser
smtp:myaddress
Here is a Regex that should match the spaces before protocols. Try plugging it into
Regex.Splitlike so: