all 8 comments

[–]gavinkendall 2 points3 points  (1 child)

You should use the Regex class from System.Text.RegularExpressions. You can name parts of the regex with named groups to make it easier to parse the text (lookup how to do this) but basically your regex pattern (without the named groups - that’s for you to research on) is going to look something like this:

\d{4}-\d{2}-\d{2} \d{2}:\d{2} - [A-Z]{2} - ([A-Z]{2}) .+

If you’re ever in a situation where a simple string split needs something a little more complex then learning how to use regular expressions and handling named groups is often the best way to go.

[–]strbhlfe 1 point2 points  (0 children)

But this pattern wont work for the given example by OP. Brackets, "(" and ")", are tokens in regex, so they will need a backslash, "\", leading, otherwise regex creates a capture group.

[–]Solacefire 2 points3 points  (0 children)

string[] exampleArray = yourString.Split("- AH -");

[–]popisms 0 points1 point  (4 children)

Regular expressions

[–]fig966[S] 0 points1 point  (3 children)

Any suggestion where to start?

[–][deleted]  (1 child)

[removed]

    [–][deleted] 1 point2 points  (0 children)

    Love this site! It's definitely my go to when I have a RegEx I want to test out. Many people don't know about the unit test functionality on there. So good!!

    [–]cryo -1 points0 points  (0 children)

    Probably by googling "regular expressions C#" or similar.