我有这串代理地址,它们用空格分隔,但是 x400 和 x500 将空格处理成它们的地址。拆分它的最佳方法是什么。
例如
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
预期结果:
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
谢谢,
编辑,
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);
}
结果
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