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 any way to split a string
, with another string being the split by parameter? I've tried converting the splitter into a character array, with no luck.
In other words, I'd like to split the string
:
THExxQUICKxxBROWNxxFOX
by xx
, and return an array with values:
THE, QUICK, BROWN, FOX
is the way I do it usually. Of course you'll need a
but than again I need that lib all the time.
There's an overload of String.Split for this:
The above answers are all correct. I go one step further and make C# work for me by defining an extension method on String:
That way I can call it on any string in the simple way I naively expected the first time I tried to accomplish this: