C# How can I split this string?
From a question I proposed an answer to on stackoverflow.com.
If you've ever looked at the properties of a user in Exchange you'll have seen a list of strings like:
You could use Regular Expressions, but, now you have two problems. I'm not going to copy my solution here lock-stock, needless to say it underwent multiple revisions and probably isn't the best one, but it seems to have made the person that asked the original question happy, and that's job done for me :)
If you've ever looked at the properties of a user in Exchange you'll have seen a list of strings like:
smtp:john.smith@company-name.comNow, imagine that these were given to you as one long semi-colon separated string... How would you split it up into say an array, or a List<string> that contained one each of those lines above, per element.
smtp:john.smith@companyname.com
SMTP:john.smith@company-name.co.uk
smtp:john.smith@companyname.co.uk
x400:C=UK; A= ;P=Test;O=CompanyName;OU=Sales;S=John; G=Smith;
x500:C=UK; A= ;P=Test;O=CompanyName;OU=Sales;S=John; G=Smith;
You could use Regular Expressions, but, now you have two problems. I'm not going to copy my solution here lock-stock, needless to say it underwent multiple revisions and probably isn't the best one, but it seems to have made the person that asked the original question happy, and that's job done for me :)
