Skip to content

strjoin

strings · scripts/strings/strjoin.m

: str = strjoin (cstr)
: str = strjoin (cstr, delimiter)

Concatenate the strings of a cell array with a separator between them.

By default the separator is one space. A character vector delimiter is placed between every pair of neighbours; escape sequences such as '\n' in it are expanded. A string array or cell array delimiter that is scalar is reused for every gap (no escape processing). A string/cell delimiter with one entry fewer than cstr supplies a different separator for every gap, also without escape processing (Oxford-comma style).

strjoin ({'red', 'green', 'blue'}, ' | ')
      ⇒  'red | green | blue'
strjoin ({'a', 'b', 'c'}, {', ', ', and '})
      ⇒  'a, b, and c'