How to split a string, but also keep the delimiters?

前端 未结 23 2383
我在风中等你
我在风中等你 2020-11-21 06:32

I have a multiline string which is delimited by a set of different delimiters:

(Text1)(DelimiterA)(Text2)(DelimiterC)(Text3)(DelimiterB)(Text4)
23条回答
  •  别那么骄傲
    2020-11-21 06:52

    I don't know Java too well, but if you can't find a Split method that does that, I suggest you just make your own.

    string[] mySplit(string s,string delimiter)
    {
        string[] result = s.Split(delimiter);
        for(int i=0;i

    Its not too elegant, but it'll do.

提交回复
热议问题