Opposite of StringSplit
A combination of StringJoin
and Riffle
:
res = StringSplit["a b c d e f g"," "];
StringJoin@Riffle[res," "]
In version 10.1 you can use StringRiffle
:
res = StringSplit["a b c d e f g", " "];
StringRiffle[res]
Use no second argument for spaces, or something else for something else. A nice advantage of StringRiffle
is that res
elements can be non string elements, and it will be automatically converted. It's something I miss in StringJoin
.
PS: this answer is based on Docs, I don't have V10.1.
Take care with ToString@Row
in V9 or older. See this post, about some problems.
Sometimes you can you this alternative:
res = StringSplit["a b c d e f g", " "];
ToString @ Row[res, " "]