Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String.Split with a String?

Tags:

c#

.net

I have what is probably a very simple question.

I want to do a classic String.Split(), but with a string, not a character. Like string.Split("word") and get back an array just like if I had done string.Split('x').

like image 960
Ryan Ries Avatar asked Dec 21 '22 07:12

Ryan Ries


1 Answers

You can use String.Split(string[], StringSplitOptions options).

The code will look like:

var results = theString.Split(new[] {"word"}, StringSplitOptions.None);
like image 112
Reed Copsey Avatar answered Jan 05 '23 11:01

Reed Copsey