Table of Contents
join
Table of Contents
Prototype: join(glue, list)
Return type: string
Description: Join the items of list
into a string, using the conjunction in glue
.
Converts a list or data container into a scalar variable using the join string in first argument.
This function can accept many types of data parameters.
Arguments:
Example:
body common control
{
bundlesequence => { "test" };
}
bundle agent test
{
vars:
"mylist" slist => { "one", "two", "three", "four", "five" };
"datalist" data => parsejson('[1,2,3,
"one", "two", "three",
"long string",
"four", "fix", "six",
"one", "two", "three",]');
"mylist_str" string => format("%S", mylist);
"datalist_str" string => format("%S", datalist);
"myscalar" string => join("->", mylist);
"datascalar" string => join("->", datalist);
reports:
"Concatenated $(mylist_str): $(myscalar)";
"Concatenated $(datalist_str): $(datascalar)";
}
Output:
R: Concatenated { "one", "two", "three", "four", "five" }: one->two->three->four->five
R: Concatenated [1,2,3,"one","two","three","long string","four","fix","six","one","two","three"]: 1->2->3->one->two->three->long string->four->fix->six->one->two->three
History: The collecting function behavior was added in 3.9.
See also: string_split()
, about collecting functions.