Search code examples
c#stringirc

Get a part of that String C#


:barbosza!barbosza@barbosza.tmi.twitch.tv PRIVMSG #pggamesbr :My text

I want the part after the second ':', but i can't split by ':' because sometimes contains it too.


Solution

  • You can split and specify the maximum number of items, so that everything after the second colon ends up in the third item:

    string[] parts = str.Split(new char[]{':'}, 3);
    

    The part after the second colon is now in parts[2].