Wolfram Language & System 11.0 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

StringRiffle

StringRiffle[{s1,s2,s3,}]
creates a string by concatenating all the si, with spaces inserted between them.

StringRiffle[{{s11,s12,},{s21,s22,},}]
creates a string by concatenating the sij, and inserting spaces at the lowest level and newlines at the higher level.

StringRiffle[list,sep]
inserts the separator sep between all elements in list.

StringRiffle[list,{"left","sep","right"}]
use left and right as delimiters after concatenation.

StringRiffle[list,sep1,sep2,]
inserts separator sepi between elements of list at level i.

DetailsDetails

  • Any element of list that is not a string is converted to a string using TextString.
  • In StringRiffle[list], spaces are used as separators at the lowest level. At the next level up, newlines are used. At each higher level, successively more newlines are used.

ExamplesExamplesopen allclose all

Basic Examples  (2)Basic Examples  (2)

Insert spaces between successive elements:

In[1]:=
Click for copyable input
Out[1]=

Insert a specific string between elements:

In[2]:=
Click for copyable input
Out[2]=

Specify delimiters to use at the beginning and end of the result:

In[3]:=
Click for copyable input
Out[3]=

Using newlines and spaces as separators:

In[1]:=
Click for copyable input
Out[1]=

Specify separators at each level:

In[2]:=
Click for copyable input
Out[2]=
Introduced in 2015
(10.1)