Collpase or remove white space in a text string without using regex

(imported topic written by NoahSalzman)

Not sure if this has been posted before. This is a handy way to turn multiple spaces or tabs into single spaces without using regex.

Q: concatenation ", " of substrings separated by " " whose (it != “”) of “foo bar baz bak”

A: foo, bar, baz, bak

Q: concatenation " " of substrings separated by " " whose (it != “”) of “foo bar baz bak”

A: foo bar baz bak

And if the white space is tab characters:

Q: concatenation " " of substrings separated by “%09” whose (it != “”) of " bar baz bak"

A: bar baz bak

There may be a better way to do both spaces and tabs, but here is the not-so-elegant “two pass” approach:

Q: concatenation " " of substrings separated by " " whose (it != “”) of (concatenation " " of substrings separated by “%09” whose (it != “”) of " bar baz bak")

A: bar baz bak