Make a string out of an array - opposite of SPLIT

Hi,

I’m very puzzled… I can easily make an array out of a string using SPLIT. But how do I reverse that?

In JavaScript:

let a = mystring.split(" ")
let s = a.join(" ")

Usecase is converting strings containing several words to TitleCase, for example “FIRSTNAME LASTNAME” to “Firstname Lastname”, which is basically quite simple:

ARRAY INITCAP(e) FOR e IN SPLIT(wtuname, " ") END

but that returns an array, not a string. So far I did a workaround:

REPLACE(REPLACE(REPLACE(REPLACE(ENCODE_JSON(ARRAY INITCAP(e) FOR e IN SPLIT(wtuname, " ") END), "[\"", ""),"\"]", ""), "\"", ""), ",", " ")

But that is very, very ugly and feels just wrong.

Hi @JulianBuss,
you can use the CONCAT2 function to join strings in an array.

1 Like

Oh boy, shame on me that I didn’t see that in the docs. Thanks!