Logo

Programming-Idioms

History of Idiom 219 > diff from v24 to v25

Edit summary for version 25 by JerrettDavis:
New C# implementation by user [JerrettDavis]

Version 24

2021-04-12, 17:27:48

Version 25

2021-08-16, 02:19:01

Idiom #219 Replace multiple spaces with single space

Create string t from the value of string s with each sequence of spaces replaced by a single space.

Explain if only the space characters will be replaced, or the other whitespaces as well: tabs, newlines.

Idiom #219 Replace multiple spaces with single space

Create string t from the value of string s with each sequence of spaces replaced by a single space.

Explain if only the space characters will be replaced, or the other whitespaces as well: tabs, newlines.

Extra Keywords
collapse repeated
Extra Keywords
collapse repeated
Code
var t = s.Replace("  ", " ");
Comments bubble
Will replace all instances of two spaces in a string.
Demo URL
https://dotnetfiddle.net/v5POhA