Split a string by another string in C#

后端 未结 10 1502
小蘑菇
小蘑菇 2020-11-22 10:17

I\'ve been using the Split() method to split strings, but this only appears to work if you are splitting a string by a character. Is there a way to split a

10条回答
  •  长发绾君心
    2020-11-22 11:08

    Regex.Split(string, "xx")
    

    is the way I do it usually.


    Of course you'll need:

    using System.Text.RegularExpressions;
    

    or :

    System.Text.RegularExpressions.Regex.Split(string, "xx")
    

    but then again I need that library all the time.

提交回复
热议问题