Splitting a string in C#

后端 未结 4 1933
北恋
北恋 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 17:52

    Use the Regex.Matches method instead:

    string[] result =
      Regex.Matches(str, @"\[.*?\]").Cast().Select(m => m.Value).ToArray();
    

提交回复
热议问题