Logo

Programming-Idioms

History of Idiom 219 > diff from v5 to v6

Edit summary for version 6 by Bart:
New Pascal implementation by user [Bart]

Version 5

2020-02-29, 15:33:07

Version 6

2020-02-29, 15:40:41

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
Imports
regexpr
Code
  t := ReplaceRegExpr('\s+',s,' ',False);
Comments bubble
Yes, you can do it with a RegEx as well.
Removes all double whitespace.