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:

smtp:john.smith@company-name.com
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;
Now, 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.

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 :)

About this Entry

This page contains a single entry by Robert Wray published on January 29, 2009 8:30 AM.

NantContrib VSSGet doesn't like property macro expansion in "path" was the previous entry in this blog.

Controls Collection cannot be modified is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 5.04