Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to split a string with two continuous spaces

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);
like image 946
Anjali Avatar asked Oct 02 '13 19:10

Anjali


People also ask

How do you split a string with spaces in Python?

Python String split() MethodThe split() method splits a string into a list. You can specify the separator, default separator is any whitespace. Note: When maxsplit is specified, the list will contain the specified number of elements plus one.

How do you split a string?

The split() method splits a string into an array of substrings. The split() method returns the new array. The split() method does not change the original string. If (" ") is used as separator, the string is split between words.


1 Answers

You can use String.Split:

var items = theString.Split(new[] {"  "}, StringSplitOptions.None);
like image 167
Reed Copsey Avatar answered Oct 04 '22 18:10

Reed Copsey