Splitting a string in C#

后端 未结 4 1931
北恋
北恋 2020-12-06 17:40

I am trying to split a string in C# the following way:

Incoming string is in the form

string str = \"[message details in here][another message here]/         


        
4条回答
  •  感情败类
    2020-12-06 18:02

    Another option would be to use lookaround assertions for your splitting.

    e.g.

    string[] split = Regex.Split(str, @"(?<=\])(?=\[)");
    

    This approach effectively splits on the void between a closing and opening square bracket.

提交回复
热议问题