JOIN

The JOIN function combines the strings within a list into a single string.

This function takes up to two pieces of input: a list of strings and an optional separator string. It outputs a single string consisting of all strings in the list joined together, in order. If applicable, the separator string will appear between each combination, marking where each string in the given list began and ended.

Declaration

JOIN(list_of_strings, separator) -> combined_string

 

Parameters

list_of_strings (required, type: list)
A list of strings you want to join together.

There is no upper limit to how many strings can be in this list, but at least two strings are required as input in order for the JOIN function to return output that differs from this input.

separator (optional, type: string)
A string to be placed in between each of the strings in list_of_strings.

Return Values

combined_string (type: string)
A string created by joining all of the strings in the given list, with (if applicable) the separator between each of them.

Examples

Below are a few examples of the JOIN function in use. This first example takes the strings in the list ["Ann", "Bob", "Carol"] and joins them into a single string. 

JOIN(["Ann", "Bob", "Carol"]) -> "AnnBobCarol"

The above example did not separate the items in the given list with any other string – that is, all the strings from the list ["Ann", "Bob", "Carol"] are mashed together – because no separator was provided as input. The following example includes the separator " ", which separates the strings in the given list with a space. Note that the separator only appears between items in the given list; it does not pop up at the beginning of the string, and it does not hang off the end.

JOIN(["Ann", "Bob", "Carol"], " ") -> "Ann Bob Carol"

Neither list_of_strings nor separator need to be hardcoded. For the last example, assume the formula has access to the following variables:

names = ["Ann", "Bob", "Carol"]  
example_string = " and "

In the following example, the JOIN function combines the strings stored in the list names and puts the string stored in example_string between them.

JOIN(names, example_string) -> "Ann and Bob and Carol"

Discussion

JOIN can be thought of as the opposite of the SPLIT function. That is, for most strings and lists of strings, let's call our examples string and list respectively, you can use SPLIT to undo what JOIN did, like so:

SPLIT(JOIN(list, string), string) -> list

Note, however, there are few edge cases where this doesn't work perfectly. If any of the item strings in list contained the value of string as a subcomponent, SPLIT will not perfectly undo what JOIN did. Consider the following example:

SPLIT(JOIN(["This is", "a string"], " "), " ") -> ["This", "is", "a", "string"]

In the above example, the JOIN function combined the strings "This is" and "a string" by putting a space between them. But the initial two strings already contained a space, and so when the SPLIT function removed all spaces from their resulting combination and put the fragments into a list, it removed both the space added by the JOIN function and the spaces that were already part of the initial strings, resulting in list output that didn't perfectly match the list input.