Lets say i have a string:
"Joe Doe is not here"
I want to split this string only where it is multiple white spaces but keep the Joe Doe as one substring.
So that the result would be:
string[] result={"Joe Doe","is","not","Here"}
Use a Regex.Split with @"\s{2,}" as the pattern - which will split wherever there are 2 or more whitespace characters.
Regex.Split(input, @"\s{2,}")
This regex requires min. 2 spaces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With