The best approach depends a little on how flexible the parsing should be, with respect to possible additional spaces and the like. Check the exact format specifications to find out what you need.
yourString.Split(new char[] { ':' }, 2)
Limit you to two substrings. However, this does not clip the space at the beginning of the second line. You can do this in the second operation after the split.
yourString.Split(new char[] { ':', ' ' }, 2, StringSplitOptions.RemoveEmptyEntries)
Should work, but will be broken if you try to split the header name containing a space.
yourString.Split(new string[] { ": " }, 2, StringSplitOptions.None);
Will do what you describe, but actually requires space.
yourString.Split(new string[] { ": ", ":" }, 2, StringSplitOptions.None);
Makes space optional, but you still have to have TrimStart() in case of more than one space.
To make the format somewhat flexible and read your code, I suggest using the first option:
string[] split = yourString.Split(new char[] { ':' }, 2);
Thorarin Jan 07 '10 at 11:11 2010-01-07 11:11
source share