How to split a string with two continuous spaces

Anjali picture Anjali · Oct 2, 2013 · Viewed 9.7k times · Source

I have a string that consists of continuous spaces like

a(double space)b c d (Double space) e f g h (double space) i

split like

a
b c d
e f g h
i

at present i am trying like this

   Regex r = new Regex(" +");
        string[] splitString = r.Split(strt);

Answer

Reed Copsey picture Reed Copsey · Oct 2, 2013

You can use String.Split:

var items = theString.Split(new[] {"  "}, StringSplitOptions.None);