Docly Developers
ExampleUpdated 17 Oct 2026

Joining and splitting strings

How to join text strings into one and split back to many strings.

Example

Code Join and split.hash

<h1>Some HTML file</h1>
#{
    let text = "hello";
    let text2 = "world";

    /* Join two strings: outputs "hello world" */
    let joined = text + " " + text2;
    write(joined);
    write("<br>");

    /* Join the items of an array: outputs "a, b, c" */
    write(["a", "b", "c"].join(", "));
    write("<br>");

    /* Split the string into an array */
    let parts = joined.split(" ");

    /* Output the first (0-indexed) word only: "hello" */
    write(parts[0]);
    write("<br>");

    /* Split with a limit: at most 2 items, outputs "a + b" */
    write("a,b,c".split(",", 2).join(" + "));
}#

Output

<h1>Some HTML file</h1>
hello world<br>a, b, c<br>hello<br>a + b