blog vipa
mój dzień to 3 filiżanki kawy

blog vipa

How to simplify the whitespaces in .NET System.String

kwiecień 20th, 2007 . by vip

If you’ve got “  some      spaces  here    in    string    ”, and want only single spaces, you can use System.Text.RegularExpressions space.
The only line would give you only one space instead of many.

C#:
  1. output = Regex.Replace(input, @”\s+”, ” “);

To remove spaces from the beggining and end, consider the String.Trim method.

Brak powiązanych wpisów

Leave a Reply