1
using System
.Collections
.Generic
;
3 namespace IEnumerableExtras
6 /// Provides extension method to split a <see cref="string"/> while keeping the separator.
8 public static class StringExtension
11 /// Split this string keeping separator in the result.
13 /// <param name="str"></param>
14 /// <param name="value"></param>
15 /// <returns></returns>
16 public static IEnumerable
<string> SplitAround( this string str
, string value )
18 var res
= new List
<string>();
25 var j
= str
.IndexOf( value, i
== 0 ? 0 : i
+ 1 );
31 res
.Add( str
.Substring( i
, j
- i
) );
34 res
.Add( str
.Substring( j
, l
) );
39 res
.Add( str
.Substring( i
) );