I need to Split a string based on a complex delimiter

Posted by Jason on Stack Overflow See other posts from Stack Overflow or by Jason
Published on 2010-03-26T20:18:28Z Indexed on 2010/03/26 20:23 UTC
Read the original article Hit count: 438

Filed under:
|
|
|

In C# I need to split a string (a log4j log file) into array elements based on a particular sequence of characters, namely "nnnn-nn-nn nn:nn:nn INFO". I'm currently splitting this log file up by newlines, which is fine except when the log statements themselves contain newlines.

I don't control the input (the log file) so escaping them somehow is not an option.

It seems like I should be able to use a comparator or a regex to identify the strings, but String.Split does not have an option like that.

Am I stuck rolling my own, or is there a pattern or framework component that can be of help here?

© Stack Overflow or respective owner

Related posts about c#

Related posts about regex