Languages
[Edit]
EN

C# / .NET - split string with more than 1 space between words

0 points
Created by:
Kelly
394

In this article, we would like to show you how to split a string when we have more than 1 space character between words in C#.

Quick solution:

Note: 

The regular expression " +" is equivalent to "[ ]+".

 

1. C# split by space regex - @" +"

Edit

Code example: 

Output:

2. C# split by regex - @" {2,8}" - split string from 2 to 8 spaces

Edit

Code example with explanation in comment:

Output:

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

C# / .NET - String (popular problems)

C# / .NET - split a string with more than 1 space between words
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join